Input() on digits


#1

hey guys,
I'm trying torun this code but no matter what I put it gives me always the same answer.
Can you check what I'm missing here?

thank you!

q= input("""how old are you?
""").isdigit()

if q >= int(18):
print ("you're a grown up!")
elif q < int(18):
print ("you're a kid!")
else:
print("insert digits for answer. (ex: 14, 20, 31...)")


#2

Not sure why you put this in functions but...

You're using a lot of things that are really unnecessary for this simple of a program. It might be better if it looked like this:

q = int(input("How old are you?" ) #Sets your variable q to an integer that is the response to your question.

#Logic
if (q>=18):
     print("You're a grownup!")
elif( q<18):
     print("You're a kid!")
else:
     print("You have to tell me your age!")

That will get it done a lot faster and easier.


#3

Thank you very much! I got why in my way it wasn't working


#4

I'm happy to be of service.


#5

Use raw_input in python2, input does a whole lot more than its name suggests.

In python3, raw_input got renamed to input


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.