Files
Learn-Python-Programming-Th…/ch04/key.points.mutable.assignment.py
T
adii1823 ee641c189f ch04
2021-10-28 17:37:54 +05:30

9 lines
230 B
Python

# key.points.mutable.assignment.py
x = [1, 2, 3]
def func(x):
x[1] = 42 # this changes the original `x` argument!
x = 'something else' # this points x to a new string object
func(x)
print(x) # still prints: [1, 42, 3]