9/26/2022

python random function

 import random


mylist = [1, 2, 3]

random.shuffle(mylist) # randomly change the order of the list


print(mylist)

print(random.choice(mylist)) # randomly choose one element from the list

没有评论: