+ 1
In Python 3 this symbols i don't understand (%=, /=, //=, -=, +=, *=, **=) please give me examples and explain also.
%=, /=, //=, -=, +=, *=, **=
3 ответов
+ 10
There is actually a difference between a = a+ b and a += b. If you are doing this on a mutable object (like a list) the first one creates a new object and the second one mutates the original one. Usually this doesn't matter but if you don't know about it, it can be a bug that's very hard to find.
+ 4
a %= b is the same as a = a % b
It works the same way for all of them