This question already has an answer here:
- Why does random.shuffle return None? 9 answers
I am doing a homework problem which asks to create a function that "Returns a list which has all the elements of l in a random order"
import random
def shufflelist(l):
toReturn = []
toReturn = random.shuffle(l)
return toReturn
print(shufflelist([1,2,3,4,5])
When I run the code, 'None' is outputted to the console.
Aucun commentaire:
Enregistrer un commentaire