+ 2
look at if statement if 10 > 5: print("10 greater than 5") print("Program ended") it work perfectly, but when I changed if statement to 10 = 5: or 10 =>5: the program runs error, otherwise using ">=", "<=", "==","<" the progam work fine. please explain
if statement - comparison marks question
4 Respostas
+ 6
There is syntax issue with 10=5 and 10 => 5 as explained below:
a). when you write ' if 10 = 5 :' then it will throw a syntax error as the syntax for if is ' if comparison :' while 10=5 is assignment
b). when you write ' if 10 => 5 :' then it will throw a syntax error as the operator used(=>) is wrong. The correct operator is >=.
+ 4
If statements run only IF its TRUE, your code is false, so you have to code a else line :)
And dont forget spaces between your fonts
+ 4
we use '=' for variable assignment not comparison that why you got error :)
+ 2
thank you guys.