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”)

19th Jun 2019, 3:15 AM
Danial
8 RĂ©ponses
+ 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)
19th Jun 2019, 7:28 AM
voja
voja - avatar
+ 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")
19th Jun 2019, 4:03 AM
voja
voja - avatar
+ 1
thank u voja !
19th Jun 2019, 4:35 AM
Danial
+ 1
thank you voja ! you are the best ;)
19th Jun 2019, 3:02 PM
Danial
0
Can you say what the error is?
19th Jun 2019, 3:56 AM
Jackson O’Donnell
0
He already explained your error It's there age= ERROR(input(....
19th Jun 2019, 4:19 AM
Lexfuturorum
Lexfuturorum - avatar
0
can you explain why i need to use int ? int()
19th Jun 2019, 4:36 AM
Danial
0
Second line of voja
19th Jun 2019, 4:37 AM
Lexfuturorum
Lexfuturorum - avatar