mercredi 25 octobre 2017

Python: More efficient way to get random slices from several lists

Here's a piece of python code I wrote to get random characters from 4 lists and append them to a separate list:

key.append(chr(upper[randint(0,len(upper)-1)]))
key.append(chr(lower[randint(0,len(lower)-1)]))
key.append(chr(nums[randint(0,len(nums)-1)]))
key.append(chr(symbols[randint(0,len(symbols)-1)]))

Is there a more elegant way to do this?




Aucun commentaire:

Enregistrer un commentaire