dimanche 14 février 2021

Program does not return "Correct" even when the right answer is input

I started learning Python last month. The following program does not return "Correct" even when the right answer is input:

import random
n1 = random.randint(2,22)
 
import random
n2= random.randint(1,20)

ans=n1+n2

message = input(f"Enter the answer to the question: {n1}+{n2}=")

print(f"Your answer is {message}")

if message == 'ans': 
    print("Correct")

elif message != 'ans':
    print("Wrong")

input()



Aucun commentaire:

Enregistrer un commentaire