+ 2
Whats the differnce?!
Why is x-1 mit true?? Its 42-1 If I use x-- its 42-1 What's the differnce?
2 Answers
+ 1
You can't just write x-1, you would have to write x = x -1
x-- is shorthand for the above.
0
not only that. what really is -- or ++ is a decrement or increment operator respectively. you can have pre or post increment operator, something you cannot do easly and clear with only "a += 1". Preincrement operator first increment and then make uae of the thing, so for example:
a = 2
print(++a)
will result in printing 3, because incrementation is Pre, means it is done first, then everything else goes on. For the post incrementation, take a look:
a = 2
print(a++)
will result in printing 2, and a will equal 3 but after it is prined.
Hope it makes some things clear!