Help, input does not work | SoloLearn: Learn to code for FREE!

0

Help, input does not work

hello everyone I’m trying to run this python code, I’m a beginner and it’s a very simple code but it does not work it gives an error can someone help me solve this thank you so much age = input(“how old are you?”) if age > 10: print(“you are old”) else: print(“you are young”)

6/19/2019 3:15:48 AM

Danial

8 Answers

New Answer

+3

Alex You have to use int() because your input is string and you have to convert it to integer. Why? Because in the line : if age > 10 you are comparing two numbers. You can't compare string and number. With integers you can do math, with string not exactly. Try these examples to see the difference between string and integer: print("2+2") print(2+2)

+6

There are two things. First, you need to convert your string input to integer. Second, in Python, indentations are important, add them after if condition and else. Here: age = int(input("how old are you?")) if age > 10: print("you are old") else: print("you are young")

+1

thank u voja !

+1

thank you voja ! you are the best ;)

0

Can you say what the error is?

0

He already explained your error It's there age= ERROR(input(....

0

can you explain why i need to use int ? int()

0

Second line of voja