lundi 26 novembre 2018

keeping track about a random choice

Is there a better way to keep track on what is the random choice (i.e. "src") and what is the other choice ("dst") than this?

x,y = "hello","kitty"
n = randint(0,1)
src,dst = (x,y)[n], (x,y)[n-1]
z = deepcopy(src)
z += dst

z
Out[51]: 'kittyhello'




Aucun commentaire:

Enregistrer un commentaire