import random


def word_scrambler(word):
    """Scramble the middle letters of a word longer than 3 letters"""

    if len(word) < 4:
        return word

    # shuffle operates in place, so a str can not be shuffled directly
    middle = list(word[1:-1])
    random.shuffle(middle)

    return word[0] + ''.join(middle) + word[-1]