1import random
2number_list = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]
3print ("Original list : ", number_list)
4
5random.shuffle(number_list) #shuffle method
6print ("List after shuffle : ", number_list)
1import random
2
3number_list = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]
4print("Original list:", number_list)
5
6random.shuffle(number_list)
7print("List after first shuffle:", number_list)
8
9random.shuffle(number_list)
10print("List after second shuffle:", number_list)
1import random
2l = list(range(5))
3print(l)
4# [0, 1, 2, 3, 4]
5
6lr = random.sample(l, len(l))
7print(lr)
8# [3, 2, 4, 1, 0]
9
10print(l)
11# [0, 1, 2, 3, 4]
12
1
2import random
3
4list = [20, 16, 10, 5]
5random.shuffle(list)
6print("Reshuffled list : ",list)
7
8OUTPUT:
9Reshuffled list : [16, 5, 10, 20]