+ 5
Python arrays - Quite complicated an assignment....
It seems to me this code: arr = [4,3,1,2] arr[0], arr[arr[0]-1] = arr[arr[0]-1], arr[0] print(arr) functions as per these steps: 1) arr[arr[0]-1] = arr[3] = 2 and arr[0] = 4 are stored "on the right" 2) arr[arr[0]-1] = arr[3] = 2 is assigned to arr[0] 3) now, arr[0] is changed to 2, so arr[arr[0]-1] = arr[1], and arr[1] is assigned value "4" previously stored "on the right". Is it so?
3 Respuestas
+ 6
Nikita, please stop spamming in the Q&A. if you keep it up you will be deactivated.
+ 2
https://docs.python.org/3/reference/simple_stmts.html
Quoting 7.2. Assignment statements
"An assignment statement evaluates the expression list (remember that this can be a single expression or a comma-separated list, the latter yielding a tuple) and assigns the single resulting object to each of the target lists, from left to right."
So yeah, your description of the process is correct.
+ 2
LONGTIE👔 lol. To late, whatever she did. You're right. She's blocked