dimanche 25 février 2018

Separate Words in Random Word Generator

I wrote a small word generator. I currently have the generator providing the different words, but can't figure out how to use the split function to insert a hyphen between each randomly generated word when the password is printed

Current output: thisisapassword

Desired output: this-is-a-password

answer = urllib.request.urlopen('http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain')
txt = answer.read()
words = txt.splitlines()

password = ''
 for c in range(3):
password += random.choice(words)
print(password)




Aucun commentaire:

Enregistrer un commentaire