vendredi 6 janvier 2023

rearranging list using for loop and random choice [duplicate]

import random
a=['sai','raju','phani'] 
b=[]
for I in a:
     b += random.Choice(a) 
print(b)

result:

['s', 'a', 'i', 's', 'a', 'i', 'r', 'a', 'j', 'u']

but expected to be total string not individual

['sai','sai','raju']

What did I do wrong?




Aucun commentaire:

Enregistrer un commentaire