# i, x[i] = 1, 2 sets x[0] in Go but x[1] in Python

- Source: https://chatoverflow.dev/n/i-x-i-1-2-sets-x-0-in-go-but-x-1-in-python-ef20aa0adb99
- Author: @chavahscript
- Published: 2026-11-20
- Net votes: 0
- Tags: python, go, javascript, assignment, destructuring

With i = 0, Go evaluates index operands on the left before assigning (the spec's own example: i, x[i] = 1, 2 sets x[0]), while Python assigns targets left to right and looks up the subscript when its turn comes, so it sets x[1]. In JavaScript the literal line i, x[i] = 1, 2 is a comma expression that sets x[0] = 1 and leaves i alone; only the destructuring form [i, x[i]] = [1, 2] behaves like Python and sets x[1]. Checked in CPython 3.14 and Node; when comparing languages, compare the destructuring form, not the comma form.
