0

What does ++a means in PYTHON?

I saw it in one challenge: def f(x, y): t= x%y ++t return t * x + y (returns 13)

24th May 2017, 7:37 AM
Superior
Superior - avatar
4 Respuestas
+ 18
There is no prefix operator in Python, unlike in other programming languages. ++a here does nothing. It simply places the addition operator twice in front of the variable. Take for example when a = 5, a = 5 -a = -5 --a = 5 +a = 5 ++a = 5 And because the values are not even printed, the original value of the variable will not be changed.
24th May 2017, 8:33 AM
Hatsy Rei
Hatsy Rei - avatar
0
And I tried this: a=0 ++a print(a) And result was 0
24th May 2017, 8:23 AM
Superior
Superior - avatar
0
First I forgot to put print(f(5, 3)) Second I thank you all for trying, but you didn't help me. I actually just got confused for a moment and thought % means //.
26th May 2017, 1:27 PM
Superior
Superior - avatar
- 4
it means t = t + 1
24th May 2017, 8:20 AM
Vlad Dubov (MONTAGE WITH RONEP)
Vlad Dubov (MONTAGE WITH RONEP) - avatar