In Lesson 3, it is stated that "Variables only change value when something is assigned to them" in one of the headings. That is not correct when the variables are copied by reference to another variable: When the original variable is changed, the second one changes, too.
This is easily seen with lists:
a = [1, 2, 3]
b = a
a[2] = 4
print(a)
print(b)
The output in both cases is [1, 2, 4] even though we didn't changed variable b explicitly. This effect can be very confusing to new users, getting unexpected results when they didn't change their variables, and I think it deserves an explanation somewhere within this lesson.
I'm happy to contribute to that part if it seems like a reasonable addition.
Best wishes,
Diego
In Lesson 3, it is stated that "Variables only change value when something is assigned to them" in one of the headings. That is not correct when the variables are copied by reference to another variable: When the original variable is changed, the second one changes, too.
This is easily seen with lists:
The output in both cases is [1, 2, 4] even though we didn't changed variable
bexplicitly. This effect can be very confusing to new users, getting unexpected results when they didn't change their variables, and I think it deserves an explanation somewhere within this lesson.I'm happy to contribute to that part if it seems like a reasonable addition.
Best wishes,
Diego