# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# #### BAD

def grow_list(val, my_list=[]):
    my_list.append(val)
    return my_list


my_list = []
my_list = grow_list(42, my_list)
my_list = grow_list(42, my_list)
my_list = grow_list(42, my_list)
print(my_list)

# +
my_list2 = grow_list(42)
print(my_list2)

my_list3 = grow_list(43)
print(my_list3)


# -

# ### GOOD

def grow_list(val, my_list=None):
    if my_list:
        my_list.append(val)
    else:
        my_list = [val]
    return my_list


# + tags=[]
my_list2 = grow_list(42)
print(my_list2)

my_list3 = grow_list(43)
print(my_list3)
# -



StarcoderdataJupyterScriptsDedupFiltered