mardi 25 octobre 2022

How to make strings not repeat in a random word generator

I am making a random string generator, however I am having issues making the strings not repeat when generating

Here's the Code:

import random
import string

repeat = True

pp = input("What's your text? ").lower()
pl = len(pp)

while repeat == True:
    letters = string.ascii_lowercase
    result_str = ''.join(random.choice(letters) for i in range(pl))
    print(result_str)
    if result_str == pp:
        repeat = False

How can I make the strings always different from one another

I've tried searching it up on google, but got no result I was happy with.




Aucun commentaire:

Enregistrer un commentaire