Output of python ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Output of python ?

Output of given program is 10 because a=5 and b=5 in the end but i did not understood why pre decrement does not change the value of a initially to 4 ? a=5 b=7 if not a!=b-2: b=--a print(a+b)

16th Oct 2019, 12:56 AM
Ahsan Ali Khan
Ahsan Ali Khan - avatar
3 Answers
+ 4
incrementing/decrementing with ++ and — isnt supported in Python
16th Oct 2019, 2:07 AM
꧁༺ Jenspi ༻꧂
꧁༺ Jenspi ༻꧂ - avatar
+ 4
It's not just about not being allowed simultaneously. As Jenny 🖤 said, the ++ and -- operators are not supported in Python.
16th Oct 2019, 3:14 AM
Sonic
Sonic - avatar
+ 2
I got it .. we can not assign and increment/decrement simultaneously. It is just changing sign of a..like b=-a means a=5 and b=-5 and for b=--a means a=5 and b=-(-5)=5
16th Oct 2019, 1:03 AM
Ahsan Ali Khan
Ahsan Ali Khan - avatar