0

x=2

if x+=1==3 then why x-=1==2 (why not 1?)

11th Mar 2020, 12:13 PM
sagor zia
sagor zia - avatar
2 Answers
+ 2
x+=1 means x=x+1. //x=2+1=3 x-=1 means x=x-1 //x=3-1=2 == comparison operator.., = is assignment operator..
11th Mar 2020, 1:12 PM
Jayakrishna 🇼🇳
+ 2
x = 2 x += 1 # add 1, x is now 3 x -= 1 # let x be itself minus 1 => 2 Makes sense?
11th Mar 2020, 12:20 PM
Ipang