Possible Duplicate:
Python splitting strings and jumbling the middle
I have a program in python that I am really stuck on, my purpose of this is to take a sentence from a user and jumble the middle of the word leaving the outer to letters intact…My teacher says I need to do something with parameters but I really have no clue how too access or use my function at all…
import random
user_words = input("Enter a word or sentence: ") #Gets user input
word = list(user_words.split()) #Creating a word list of the user input
def Jumble_One_Word(x):
if len(user_words) > 2: #Only need to change words longer than 2
first_letter = user_words[0] #Takes the first letter out and defines it
last_letter = user_words[-1] #Takes the last letter out and defines it
letters = list(user_words[1:-1]) #Takes the rest and puts them into a list
random.shuffle(letters) #shuffles the list above
middle_letters = "".join(letters) #Joins the shuffled list
final_word = "".join([first_letter, middle_letters, last_letter]) #Puts final word all back in place as a list
print(final_word)#Prints out the final word all back together again
Jumbler_Count = -1
for i in range(len(word)):
Jumbler_Count + 1
Word1 = Jumble_One_Word(word[Jumbler_Count])
SAMPLE INPUT: HELLO MY NAME IS
EXPECTED OUTPUT: HLELO MY NMAE IS
RESULTED OUTPUT: H leai El moymns
Hoi ynmeEa lm ls
Hiyn l oelEamms
H naellmEyo m is
you need to work on
xinside the function, and you were working onuser_wordsinstead.output: