if statements | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

if statements

when I use the if statement like this: iiS = 2 if iiS = 2: print ('IHaveProblem') I get an error and I dont know why... It says the = isnt part of the syntax... but it is right? So if you know what Im doing wrong please reply...

25th Mar 2017, 5:11 PM
privrax.
privrax. - avatar
7 Answers
+ 9
iiS = 2 if iiS ==2: print('IHaveProblem')
25th Mar 2017, 5:15 PM
Sachin Artani
Sachin Artani - avatar
+ 8
@privrax, read meharban's comment.
25th Mar 2017, 5:18 PM
Sachin Artani
Sachin Artani - avatar
+ 5
replace = with == in if clause = is an assignment operator, meanjng that it is used to assign values, and not to test values. == is a condition checker, and returns true if both the values before and aftee == are same.
25th Mar 2017, 5:17 PM
Meharban Singh
Meharban Singh - avatar
+ 5
Nice✓
25th Mar 2017, 5:21 PM
Meharban Singh
Meharban Singh - avatar
+ 1
It says its on the second line: 1. iiS = 2 2. if iiS = 2: ^ SyntaxError
25th Mar 2017, 5:17 PM
privrax.
privrax. - avatar
+ 1
Thanks guys! Your awesome!
25th Mar 2017, 5:18 PM
privrax.
privrax. - avatar
+ 1
It worked! :D
25th Mar 2017, 5:20 PM
privrax.
privrax. - avatar