use SystemRandom for randomshuffle instead of own rolled implementation

This commit is contained in:
Kevin Froman 2020-10-19 07:28:38 +00:00
parent 3ca05e2390
commit 183e6491d0

View File

@ -1,13 +1,6 @@
import secrets
from random import SystemRandom
def random_shuffle(theList):
myList = list(theList)
shuffledList = []
myListLength = len(myList) + 1
while myListLength > 0:
removed = secrets.randbelow(myListLength)
try:
shuffledList.append(myList.pop(removed))
except IndexError:
pass
myListLength = len(myList)
return shuffledList
SystemRandom().shuffle(myList)
return myList