Sobes.tech
Junior — Senior

Copying a list with a slice and subsequent modification

livecode

Task condition

Understand how lists behave when creating a copy using slicing and subsequent modifications. What output will be obtained?

lst = [1, 2, 3]
copy_lst = lst[:]

lst.append(4)
copy_lst += [4]

print(lst)
print(copy_lst)