- Shuffle() is a python function which is predefined in random library
- It is used in shuffle the sequence like list.
- Shiffle don't work on the set and tuple because they are immutable data type in python.
Example-
list is [2,3,4,5,8]
after shuffle it may be [3,8,4,2,5] or [8,2,5,4,3] etc.
program-
import random
print("Enter element in list")
l=list(map(int,input().split()))
print("Original list is ",l)
random.shuffle(l)
print("Shuffle list is ",l)
Enter element in list
2 3 5 4 7 8
Original list is [2, 3, 5, 4, 7, 8]
Shuffle list is [7, 3, 4, 5, 8, 2]
Enter element in list
12 3 45 67 21
Original list is [12, 3, 45, 67, 21]
Shuffle list is [21, 12, 67, 3, 45]