+ 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 Respuestas
+ 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