If statement | Sololearn: Learn to code for FREE!
+ 1

If statement

Why this code shows invalid syntax? if s/p=0: ÔÇťI have variables called s and pÔÇŁ

15th Sep 2021, 3:18 PM
Hanistan
6 Antworten
+ 5
To compare numbers you need to use ÔÇś==ÔÇś not ÔÇś=ÔÇś
15th Sep 2021, 3:20 PM
Brain & Bones
Brain & Bones - avatar
+ 1
Thank you
15th Sep 2021, 3:21 PM
Hanistan
+ 1
cz in comparision you supposed to use equal to operator "==" hint: use spaces it will make you code more readable
15th Sep 2021, 4:03 PM
ox titanium
ox titanium - avatar
+ 1
The '=' is an assignment operator. The '==' is a comparison operator. Selection (if, elif, else) and repetition (for, while, do while) statements use comparisons for checking. The proper comparison should be s / p == 0
15th Sep 2021, 8:11 PM
Marvin
Marvin - avatar
0
I forgot that
15th Sep 2021, 3:21 PM
Hanistan
0
Hanistan No problem. Happy coding ­čśë
15th Sep 2021, 3:33 PM
Brain & Bones
Brain & Bones - avatar