mardi 23 juin 2020

how can i unshuffle function in python by the pattern of list?

o is the standard of pattern to un_shuffle

o = [2,1,3,0]
a = 'abcd'

def un_suffle(s,o):
   s = 'bcda'
   return ''.join([s[i] for i in o])
print(un_suffle(s,o))

my output is:

dcab # i want to make it abcd in output

Aucun commentaire:

Enregistrer un commentaire