Why doesnt this work?

Question:
Why Doesn’t this work?

Repl link:
https://replit.com/@HeartOfBedrock/JitteryRashTrapezoids?v=1

code snippet:
import math
a=23
b = input("Enter a number:")
if b==a : print("Correct!")
else: print("Wrong! Try again!")

you need to convert b to integer or it will compare the wrong value of b. Of course would be great if you check also if the unput value is a number to manage errors.

4 Likes

what @whileTRUEpass said. How to do this is to wrap the input() in an int(), so, int(input(“Enter a number:”))

Yes that works. Although it’s always good to either include a space after an input or \n (new line) because otherwise there’s no gap between the input statement and the user’s input.
Enter a number:1 becomes Enter a number: 1.