jeudi 5 septembre 2019

Random.shuffle() in a function [duplicate]

This question already has an answer here:

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