ShuffleΒΆ
Sometimes we want to take the elements in a list, and put them into a random order.
Luckily, Python thought of that for us.
>>> import random
>>> my_list = [5, 1, 3, 2, 7]
>>> my_list
[5, 1, 3, 2, 7]
Now we shuffle the elements to a random order:
>>> random.shuffle(my_list)
>>> my_list
[1, 7, 3, 2, 5]
>>> random.shuffle(my_list)
>>> my_list
[2, 5, 3, 1, 7]
>>> random.shuffle(my_list)
>>> my_list
[7, 3, 2, 5, 1]