What happens when you assign the value of one variable to another variable in Python?

后端 未结 10 849
太阳男子
太阳男子 2020-11-30 00:54

This is my second day of learning python (I know the basics of C++ and some OOP.), and I have some slight confusion regarding variables in python.

Here is how I unde

10条回答
  •  广开言路
    2020-11-30 01:33

    When you store spam = 42 , it creates an object in the memory. Then you assign cheese = spam , It assigns the object referenced by spam to cheese. And finally, when you change spam = 100, it changes only spam object. So cheese = 42.

提交回复
热议问题