+ 2

DOES ++ OPERATOR EXIST IN PYTHON???

There was quiz that uses ++ statement. This is code from it: def p(x,y): t=x%y ++t return t*x+y print(p(5,3)) And it works! Although in the course said that there isn't ++ operator in python. Maybe, it works only in functions?

4th Aug 2018, 6:21 PM
<<Meowg!i>>
<<Meowg!i>> - avatar
9 ответов
+ 6
Hup, my bad. ++ is not really an operator. It's an association of two operators ( + and + ) ++var => + ( + var ) So yes, you can use this ( sorry if I said not, my mistake ;) )
4th Aug 2018, 6:31 PM
Chalza
Chalza - avatar
+ 3
<<Meowg!i>> I just removed the ++t from the function. the output is the same
4th Aug 2018, 8:25 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 1
Choubada, but try this code: https://code.sololearn.com/crHSqA6k20H3/?ref=app ++ works here. And this code is from SoloLearn's quiz
4th Aug 2018, 6:27 PM
<<Meowg!i>>
<<Meowg!i>> - avatar
+ 1
Thank you, Choubada! It means that this line don't do anything? It's writed to confuse, isn't it?
4th Aug 2018, 6:38 PM
<<Meowg!i>>
<<Meowg!i>> - avatar
+ 1
Thanks, KKK! One more question: does program call variable/number and does it take up space in memory if i only write it, like in this code: а=123 а +++---10 -10*а +-+-+-а I know that it hasn't real application, just wondering :)
4th Aug 2018, 10:04 PM
<<Meowg!i>>
<<Meowg!i>> - avatar
0
No, it doesn't exist, sorry ;) PS: You can use +=1
4th Aug 2018, 6:23 PM
Chalza
Chalza - avatar
0
try post decrement operator of c in python 😂
4th Aug 2018, 9:03 PM
Kalyan
Kalyan - avatar
0
print(2--+6) output: 8
4th Aug 2018, 9:05 PM
Kalyan
Kalyan - avatar