Put error handling inside a loop when one bad value should not discard later entries. The continue statement starts the next iteration.
A kiosk looks up one price at a time. An unknown code skips only that purchase.
prices = {"A": 4, "B": 6}
total = 0
for code in ["A", "X", "B"]:
try:
price = prices[code]
except KeyError:
continue
total += price
print(total) # 10The next iteration still processes B. Apply the same control flow to values that fail a conversion.
Return a list of the integer readings from a list of strings. Skip any entry that cannot be converted with int. Preserve the order, including negative numbers and zeros.
good_readings(["3", "?", "-1", "0"]) # [3, -1, 0]