import random
number_letter = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"]
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
#print(spell)
#print(number_letter[numbers.index(spell)])
score=0
wrong=0
tries = 3
question =0
while question <= 10:
spell: int = random.choice(numbers)
guess = input(f"Spell {spell}:")
right_answer = number_letter[numbers.index(spell)]
if guess == right_answer:
score= score +1
question= question +1
print("You spelled it right!")
else:
tries= tries - 1
print("Incorrect Spelling.",tries,"left")
if tries == 0:
wrong = wrong + 1
print("Number of trial Exceeded")
in this program i need to spell the number if its wrong it will have a 3 tries and if the 3 tries is over it will become wrong answer then the program will continue until the user solve 10 question. please help me
import random
number_letter = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"]
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
score = 0
wrong = 0
tries = 3
question = 0
while question < 10:
spell = random.choice(numbers)
while tries > 0:
guess = input(f"Spell {spell}: ")
right_answer = number_letter[numbers.index(spell)]
if guess.lower() == right_answer.lower():
score += 1
print("You spelled it right!")
question += 1
break
else:
tries -= 1
print(f"Incorrect Spelling. {tries} left")
if tries == 0:
wrong = wrong + 1
print("Number of trial Exceeded")
tries = 3
Comments
Leave a comment