I want to iterate over a list, print the elements and remove them. (I'm interested in the principle not the outcome i know i can use list.clear) I'm trying this code:
def function(list):
for i in list:
print(i)
list.remove(list[0])
list = [1,2,3]
function(list)
print(list)
and getting weird output:
1
3
[3]
Any thoughts?