Well you can use your Browser, since
JavaScript understand post and pre increment:
> x = 5
5
> x ++
5
> x = 5
5
> ++ x
6
So we have x ++ equals in Python:
x + = 1
x - 1
And ++ x equals in Python:
x += 1
x
But I don't know how to combine an
assignment and an expression into one
expession. In JavaScript one can use
the comma:
> x = 5
5
> y = (x += 1, x - 1)
5
> x = 5
5
> y = (x += 1, x)
6
But in Python the comma would create a tuple.
Lawrence D'Oliveiro schrieb:
On Thu, 07 Nov 2024 12:55:53 +0530, Annada Behera wrote:
I heard this behavior is because python's integers are immutable.
Nothing to do with that.
++x or x++ will redefine 5 to 6, which the interpreter forbids ...
One of those is actually syntactically valid.
It just won’t do what you expect it to do.
--
https://mail.python.org/mailman/listinfo/python-list