Remove Items While Iterating
Interview insights are lockedSee how often this is asked and which companies asked it with Buncho Pro.You clean invalid records from a list with this loop, but some bad records survive.
nums = [2, 4, 6, 1]
for n in nums:
if n % 2 == 0:
nums.remove(n)
print(nums)
What does it print, why, and what is the safer approach?