What I was trying to do (C code):
int a = 2, b = 3, c = 4;
int* arr[3] = {&a, &b, &c};
for (int i = 0; i < 3; ++i) {
if (*(arr[i]) > 1) {
*(arr[i]) = 1
}
}
I was expecting Python to do similar pointer like behavior with this piece of code.
>>> a = 2
>>> b = 3
>>> c = 4
>>> for x in [a, b, c]:
... if x > 1:
... x = 1
...
>>> a,b,c
(2, 3, 4)
How can the C code like behavior be achieved in Python?
x is a(etc. forb, c), you'll see it's the same object.