Which fix removes the crash?
def parse(rows):
return [int(r) for r in rows]
parse(['1', 'x', '3'])
- Keep only digits: filter with
r.isdigit() - Keep only digits: filter with
r.isnumeric - Wrap each
int(r)in a bare try block - Change the list into a generator instead
int() raises on a non-numeric string, which aborts the whole comprehension.
Play Problem Solving ▸