vendredi 31 juillet 2020

List won't shuffle [duplicate]

I am attempting to make a mini-game in which the user must unshuffle a word. The word is taken at random from a list, saved as w, then shuffled as s. To achieve this I attempted to take the word from the list and turn it into a list itself so that the letters can be shuffled. Yet python only ever returns None.

from random import shuffle
import random

words = ["help"]

w = (random.choice(words))
print(w)

s = list(w)
print(s)
s = random.shuffle(s)

print(s)

The output ends up looking like this:

help
['h', 'e', 'l', 'p']
None

I can't see what I am doing wrong.




Aucun commentaire:

Enregistrer un commentaire