I need help to figure out why my if Statment is being ignored

when i run this code in Visual Studio and input 21 into the terminal it doesn’t print hello.
So my question is, is it because i simply coded it wrong or is it an underlying issue with Visual Studio .

#This is the first attempt to print hello.

print(“How old is Moxxie ?”)
input ()
if input == 21:
print(“hello”)

This is the second attempt to make this work and print hello.

print(“How old is Moxxie ?”)
Moxxie = input ()
if Moxxie == 21:
print(“hello”)

It’s a bug in your code.

Your second example:

 print("How old is Moxxie ?")
 Moxxie = input ()
 if Moxxie == 21:
     print("hello")

The return from input() is always a string. A string is never equal to
an int (your 21) - they’re different types. You need to convert that
to an int. This is usually done like this:

 print("How old is Moxxie ?")
 Moxxie_s = input ()
 Moxxie = int(Moxxie_s)
 if Moxxie == 21:
     print("hello")

which computes a new int by parsing Moxxie_s.

Often this is written more compactly:

 print("How old is Moxxie ?")
 Moxxie = int(input ())
 if Moxxie == 21:
     print("hello")

Cheers,
Cameron Simpson cs@cskk.id.au

Awesome I tried converting it to an int and it worked thanks .