Global variables mutable in functions
a = [2]
def f():
print(a) # [2]
a.append(3)
print(a) # [2, 3]
a[0] = 4
f()
print(a) # [4, 3]
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
a = [2]
def f():
print(a) # [2]
a.append(3)
print(a) # [2, 3]
a[0] = 4
f()
print(a) # [4, 3]