x = [1,2,3]
y = x
y.append(4)
print("y after append", y)
# x and y are ALIASED -- so when we append to y,
#  we also change x!
print("x after append", x)

###

# lst is an alias for the argument, so when we
#  modify lst, the changes are seen
#  outside the function call.
def mutatingDouble(lst):
    for i in range(len(lst)):
        lst[i] = lst[i] * 2

x = [1,2,3]
print("x before mutatingeDouble", x)
y = mutatingDouble(x)
print("x and y after mutatingDouble", x, y)

###

# Here, we don't change lst, so
#  it stays the same. Instead, we return the
#  newly-calculated values in a new list.
def nonMutatingDouble(lst):
    result = []
    for i in range(len(lst)):
        result.append(2 * lst[i])
    return result

x = [1,2,3]
print("x before nonMutatingDouble", x)
y = nonMutatingDouble(x)
print("x and y after nonMutatingDouble", x, y)