This method shuffles the given string or an array. It randomizes the items in the array. This method is present in the random module. So, we need to import it and then we can call the function. It shuffles elements each time when the function calls and produces different output.
import random
list = [12,25,15,65,58,14,5,];
print(list)
random.shuffle(list)
print (“Reshuffled list : \n”, list)
[12, 25, 15, 65, 58, 14, 5]
Reshuffled list :
[58, 15, 5, 65, 12, 14, 25]