Daily #20 · 18 October 2026
Removing the twos Medium
What does this print?
nums = [1, 2, 2, 3]
for n in nums:
if n == 2:
nums.remove(n)
print(nums)
Show the answer
C: [1, 2, 3]
Why: Removing an item shifts everything after it one place left, and the loop moves on to the next position, so it skips the second 2. Build a new list instead: [n for n in nums if n != 2].