+ 2
Increment & decrement operators [python]
Okay so I've read that in python, the operators '++', '--' etc. are not implemented (like in c++). I also get the reason behind: they are not needed as often, thanks to iteration with range(8), and so on. But then what exactly happens when someone does use them? After testing: c = 0 c = ++c # seemingly nothing changes c = c++ # throws syntax error
2 Respostas
+ 2
you cannot use this operators, because they are not implemented
when you do c=++c, it is something like c= -c. The second changes the sign of the number. When you use + instead of -, it doesn't change the sign. ++c is the same operation applied twice, so c=++c is the same as c=c
+ 1
thanks, makes sense