lst = [1, 2, 3, 4, 5, 6]
for item in lst:
if item > 3:
lst.remove(item)
print(lst)
output: >>> [1, 2, 3, 5] How come this code doesn't produce the output of "[1, 2, 3]"? I've tried to work around this but the only way I can think of is appending the items larger than 3 to a new list. Thanks for any feedback.