-1

I just started learning how to code yesterday and I can't figure out what could be wrong with this:

print("Enter yout age: ")

    age = input()

    if age == 0:
        print("So you don't exist?")
    else:
        print("So you do exist!")

When I run that even if I input "0" it ignores the if line and I get "So you do exist!" every time.

3 Answers3

1

Convert the input to int. Use proper indentation.

print("Enter your age: ")
age = int(input())
if age == 0:
    print("So you don't exist?")
else:
    print("So you do exist!")
srikavineehari
  • 2,502
  • 1
  • 11
  • 21
0

yeah because input() return type is str; use age = int(input())

tso
  • 4,732
  • 2
  • 22
  • 32
0

You are comparing a string to a number, so it's wrong. If you parse it, you will be able to compare :)

Try this:

print("Enter yout age: ")
age = int(input())
if age == 0:
    print("So you don't exist?")
else:
    print("So you do exist!")
Víctor López
  • 819
  • 1
  • 7
  • 19