What is the purpose of `index +=1`?

You’re correct in that this is incorrect. When assigning variables values, the expression on the right side of the assignment operator (=) is evaluated, then assigned to the variable on the left. Here, you are trying to assign 1 + index the value of index. 1 + index is not a valid variable name and will throw an error. You’re nearly there though!

You see what they mean by how weird this appears on first glance?

a = a + 1

The reverse can never be true.

a + 1 = a

The complexity of the mind is something we must always be wary of. IT sees these anomalies long before we do.

Thank you for helping me work through this.

1 Like