- 1

Problem with python script

Variable = input("Your number is ") if Variable = 50 print("I dont like your number") else print("I like your number") syntax error? Solved by N3tW0rk

11th Feb 2017, 7:54 AM
Mikolaj Slomczewski
Mikolaj Slomczewski - avatar
5 ответов
+ 4
it must be if Variable == 50: # Double = and : after 50 print("....") else: # : here too print("---") double == to compare and one to assign a value to a variable and respect indentation
11th Feb 2017, 7:58 AM
Kawaii
Kawaii - avatar
+ 3
u should put Variable = int(input("---")) too instead of just input cause just input is string
11th Feb 2017, 8:06 AM
Kawaii
Kawaii - avatar
+ 1
works now, the else was indented and it shouldnt have been
11th Feb 2017, 8:07 AM
Mikolaj Slomczewski
Mikolaj Slomczewski - avatar
0
It now says theres a syntax error on line 4 aka else:
11th Feb 2017, 8:04 AM
Mikolaj Slomczewski
Mikolaj Slomczewski - avatar
0
Along with the == issue you need to add a : to the end of your if and else statements. You should also wrap your input () with int () otherwise you're comparing a string "50" to an integer 50. variable = int(input("Your number is ")) if variable == 50: print("I dont like your number") else: print("I like your number")
11th Feb 2017, 8:11 AM
ChaoticDawg
ChaoticDawg - avatar