0

Why is this only returning some of the items?

lst = ["!apple", "!green", "!blue", "one"]
new_list = [lst.pop(idx) for idx,i in enumerate(lst) if i.startswith("!")]
print(new_list)

Returns:

['!apple', '!blue']
M4cJunk13
  • 419
  • 8
  • 22

0 Answers0