+ 2
How this code works?
x=3 b=7 b=--x print(b) #ouput=3 but why can anyone explain this code that how is worked.
4 Answers
+ 18
In Python :
increment or decrement are not allowed ...
so the b is assigned the value of x without decrement...
check out this link for more đ
https://www.geeksforgeeks.org/g-fact-21-increment-and-decrement-operators-in-python/
+ 2
b=--x means you assign a new value to variable b which is minus minus x = 3
b-=x means you decrement the value of b by x which is b-x=4