mercredi 6 octobre 2021

Why is python bypassing this if statement to the else regardless of conditional? [duplicate]

I am a relative newcomer to programming but i am comfortable with the syntax of python but i cannot understand why this is bypassing my if statement and going directly to the else option:

import random

x = random.randint(25, 50)

print("Question 1: ")
print("What is the area of a square if one side is %s CM Long?" % x)

user_answer = input("What is your answer? ")
real_answer = x * 2


if user_answer == real_answer:
    print(f"Correct! indeed the answer was {real_answer} CM squared")

else:
    print(f"Incorrect The answer was actually {real_answer} CM squared")

Aucun commentaire:

Enregistrer un commentaire