This is a multiplication test generator. When I enter the correct answer, it still displays the message "No. Please try again."
import random
answer = 0
def generate_numbers():
num1 = random.randrange(0,10)
num2 = random.randrange(0,10)
return(num1, num2)
def display_question(answer):
num1, num2 = numbers
answer = num1 * num2
guess = int(input(f'What is {num1} times {num2}?'))
while guess != answer:
print("No. Please try again")
display_question()
print("Very good!")
Aucun commentaire:
Enregistrer un commentaire