Hi there,
I am a little bit confused as I am trying to use very simple functions on lists.
My code is:
def function_list(l):
l[0] = “C”
return l
list_1 = [“A”, “B”]
print(list_1)
list_2 = function_list(list_1)
print(list_1)
and it returns
[‘A’, ‘B’]
[‘C’, ‘B’]
Can anyone explain why list_1 gets modified even tho the function is called on list_2 ?
What should be the code in order not to modify list_1 ?
Thanks for your responses.