How do I randomly select a character from a string of characters every time I want it to be changed, for example:
import random
def user_input():
chars = 'abcdefghijklmnopqrstuvwxyz'
present = random.choice(chars)
while True:
print present
to_eval = raw_input('Enter key: ')
if to_eval == present:
print 'Correct!'
break
else:
# change the key and ask again
user_input()
Aucun commentaire:
Enregistrer un commentaire