Skip to content

Variables copied by reference not mentioned in Lesson 3 #370

@dalonsoa

Description

@dalonsoa

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood issue for first-time contributorshelp wantedLooking for Contributorstype:enhancementPropose enhancement to the lesson

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions