Passing Doesn't Mean Sharing
def append_item(lst, item):
lst.append(item)
def replace_item(lst, item):
lst = [item]
nums = [1, 2, 3]
append_item(nums, 4)
replace_item(nums, 99)
print(nums)
append_item and replace_item each receive nums as their lst parameter, but only one of them changes what nums looks like from the caller's side. What does print(nums) output? Write the exact list Python would print.
Sign in to answer questions and track your progress
Sign In