+ 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

5th Aug 2016, 3:39 PM
Soi Con
Soi Con - avatar
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 >=.
5th Aug 2016, 6:30 PM
Sruti Sarayan
+ 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
5th Aug 2016, 4:05 PM
Andreas Kilian
Andreas Kilian - avatar
+ 4
we use '=' for variable assignment not comparison that why you got error :)
6th Aug 2016, 8:11 PM
ah shabrawy
ah shabrawy - avatar
+ 2
thank you guys.
7th Aug 2016, 2:36 AM
Soi Con
Soi Con - avatar