Changing the position of the sequence’s elements is referred to as shuffling. To shuffle list in python, use the random.shuffle() method.
Syntax:
random.shuffle(sequence, function)
import random
list1 = [5,7,2,9,1,0]
print("Initial list : ")
print(list1)
# shuffling the list
random.shuffle(list1)
print("After shuffle : ")
print(list1)
Output:
Initial list :
[5, 7, 2, 9, 1, 0]
After shuffle :
[5, 0, 2, 9, 7, 1]
Also Read:
Select Random item from Tuple : Python