This is my code:
import random
letters = ['a','g','s','s','c','v','e','g','d','g']
random_letter = random.choice(letters)
guesses_left = 5
while guesses_left > 0:
guess = input("Your guess: ")
if guess == random_letter:
print ("You win!")
break
guesses_left -= 1
else:
print ("You lose.")
My question: Why am I able to type other types than strings? For example, if I run the code and answer with an integer I don't get error. If this problem is not fixable, is there a better way to create this type of game?
Aucun commentaire:
Enregistrer un commentaire