vendredi 21 octobre 2016

Shuffling a User Input Sentence

For my code, I'm trying to get the user to enter a sentence then the code will output the sentence but the words will be shuffled in a random order.

The user input could be 'Sentences are nice' and the output could be 'nice sentences are' or something. I've tried almost everything including .split but nothing works.

This is my current code that does not work.

from random import shuffle
print ("Now let's try list sort")
print ('Please enter a sentence with more than one word')
print ('')
words = input('')
outputString = words.split()
shuffle (outputString)
return ''.join(outputString)
print (outputString)




Aucun commentaire:

Enregistrer un commentaire