Shuffle a python list without using the built-in function

前端 未结 3 1791
情书的邮戳
情书的邮戳 2021-01-15 18:31

I\'m working on writing two different shuffle functions.

The first shuffle function must take a list and return a new list with the elements shuffled into a random o

3条回答
  •  深忆病人
    2021-01-15 18:47

    You can use this:

    import random
    def shuffle(lst):
         return sorted(lst ,key = lambda i,random.ramdom())
    

提交回复
热议问题