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
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")
0
Greif thanks for the help bro