Given this source list:
source_list = [2, 3, 4]
and this function:
def function(list_in):
list_in.append(5)
list_in.insert(0, 1)
return list_in
As expected, I get:
>>> function(source_list)
[1, 2, 3, 4, 5]
But if I call the variable source_list outside of the function I still get:
>>> source_list
[1, 2, 3, 4, 5]
Is there an alternative way of modifying (specifically appending/prepending to) a list within a function such that the original list is not changed?