Why doesnt this work?

Why Doesn’t this work?

Repl link:

code snippet:
import math
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.


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.