+ 1
Don't understand why you would want to write x=x+3 as x=+3?
for some reason I can't wrap my head around the logic, will appreciate it if someone will explain to me, thanks!
6 Answers
+ 4
x+=3 is a shortcut way for x=x+3
+ 1
Thanks guys!
+ 1
It's a lot clearer to me
0
It's simply a shortcut, and it doesn't affect readability, and because people want to be more efficient, people do +=, -=, *=, /=, etc.
There is nothing wrong with doing x = x + 3.
0
The longer the left hand side is, the more useful this shorthand is, also if you are assigning to an array/list/dict element, the index/key is calculated once instead of twice