mardi 4 décembre 2018

Python random choice duplicate

So i am creating a simple script, which involves creating a random string of letters. I am currently using this code, which works, but not the way that i need it to work. It doesn't output any duplicate letters, which i need

for i in range(x):
  letter=random.choice(string.ascii_letters)
  string+=letter
print(string)

the problem is that i don't get any duplicates in their, which i really need, for this code to work. I have seen how to fix for numbers but not any for letters. Any solutions are greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire