samedi 3 novembre 2018

Randomly pick characters to make a word

lets say I want to make my name goofy with different variations randomly.

i have the name BoA - i could do something like this right?

import random
list1=['B', '13', 'ß']
list2=['o', 'ø', 'Ö']
list3=['A', 'Ä', 'Á']
random1=random.randint(0,3)
random2=random.randint(0,3)
random3=random.randint(0,3)
print(list1[random1]+ list2[random2]+ list3[random3])

>> BøÁ

is there an easier way for me to do this? I just want to know what all my possibilities are. Also, I do get this error. It works fine if its regular characters, so i'm not sure how to fix that.

File "main.py", line 2
SyntaxError: Non-ASCII character '\xc3' in file main.py on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Thanks !




Aucun commentaire:

Enregistrer un commentaire