importmathimportrandomdefshuffle(list):counter=len(list)# while there are elements in the list
whilecounter>0:# pick a random index
index=math.floor(random.random()*counter)# Decrease counter by 1
counter=counter-1# And swap the last element with it
temp=list[counter]list[counter]=list[index]list[index]=tempreturnlist