def append_four(lst: list):
lst.append(4)
a = [1, 2, 3]
append_four(a)
print(a) # [1, 2, 3, 4]
When append_four is called, a list object is passed into the function as argument. Parameter lst contains the reference to the object. append_four calls the method append of the object.
Comments
Leave a comment