assume L is a list f and g are defined function
def function(L,f,g):
    newL = list()
    for i in L:
        if g(f(i)) == True:
            newL.append(i)
    L[:] = newL
    if len(L) == 0:
        return -1
    else:
        return max(L)
def f(i):
    return i + 2
def g(i):
    return i > 5
L = [0, -10, 5, 6, -4]
print(function(L, f,g))
print(L)
Using L = newL[:] will cause print(L) to print L = [0, -10, 5, 6, -4]. But if inside function I use L[:] = newL, print(L), this will make print(L) give me the result of newL [5,6] - which is what I want To me, both L = newL[:] and L[:] = newL will give me the same result. But in reality, it did not. So, can anyone provide me an explanation of this?
 
    