I am having trouble with a program in python…I need the program to jumble the middle of words while keeping the outer two letters intact…I believe I have successfully split the word into three different sections, I just can’t figure out how I am supposed to scramble the middle of the word
word = input("Enter a word")
first_letter = word[0]
last_letter = word[-1]
still_to_scramble = word[1:-1]
Should I use randoms? Or is there a simple way, sorry I am relatively new to coding.
You can use
shufflefrom the random package:Here’s how it would work:
Be careful and don’t do this:
shuffleworks in place – that’s a fancy way of saying it does’t return the shuffled bit, but modifies it instead. It actually returnsNone, and you may get tripped up by it, since you won’t see an error: