Why cant i insert( input )function with( if) statement ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why cant i insert( input )function with( if) statement ?

Im new to python...can anyone plz tell me whts wrong with my code ? https://code.sololearn.com/co9KNb8JzHfN/?ref=app

8th Dec 2019, 11:59 AM
Sandun Rathnayake
2 Answers
+ 1
There is ˋˋSyntaxErrorˋˋ because you need a colon ˋ:ˋ at the end of the second ˋˋifˋˋ-statement, and then a ˋˋTypeErrorˋˋ occurs because ˋˋinputˋˋ function always returns a string and you can‘t compare an ˋˋintˋˋ and ˋˋstrˋˋ in Python. You should change your code to convert the input to a number, e. g.: num = int(input("enter a number")) # Use ˋˋintˋˋ function to convert a ˋˋstrˋˋ to an ˋˋintˋˋ. if num > 5: print("big") if num >= 50: # Add a colon. print("very big")
8th Dec 2019, 12:27 PM
Greif
0
Greif thanks for the help bro
8th Dec 2019, 12:32 PM
Sandun Rathnayake