Returning Values Using Functions that Modify Parameters

In [1]:
a = "A String"
b = ["A", "List"]
c = ("A", "Tuple")
d = 10
In [7]:
def mod_list(lst):
    print("inside mod_list:", id(lst))
    lst[0] = "foo"
    lst[3] = "bar"
In [11]:
def main():
    my_list = ["Spam", "Ham", "Whatever", "Boo"]
    print("outside mod_list:", id(my_list))

    print(my_list)
    # main() is the caller of the function mod_list
    result = mod_list(my_list)
    print(result)
    print(my_list)
    
main()
outside mod_list: 4495159944
['Spam', 'Ham', 'Whatever', 'Boo']
inside mod_list: 4495159944
None
['foo', 'Ham', 'Whatever', 'bar']
In [ ]: