Space Python Loading Python…

Survive bad lines

Write the codeMedium 2 stages

The feed parser from "Skip blanks and comments" now converts each value to a number. Then a cabin sensor failed and started sending ERR, and the first bad value stopped the whole parse: one broken sensor, and no telemetry at all.

Make the parser skip what it can't read, keep everything else, and say how much it skipped.

The program stops at ERR with a ValueError. Put the conversion in try; when it fails, add 1 to a new counter, skipped, and go on to the next line. At the end, report all three numbers:

09:30:05 ENG-2: 412.5 C
09:30:05 TANK-1: 78.3 %
Damaged line: 2026-03-14T09:30:10Z,TANK-1
09:30:10 ENG-2: 415.0 C
09:30:15 CABIN: 101.2 kPa
Parsed: 4, damaged: 1, skipped: 2

4l7.9, with a letter l, is a typo from the ground station's operator, so it is skipped too.

Keep going past bad values

Finish stage 1 to unlock this stage.

Unpacking a line with too few fields raises ValueError too. Drop the length check and let one try cover both the unpacking and the conversion. For each line it skips, print the line and the error's message:

09:30:05 ENG-2: 412.5 C
09:30:05 TANK-1: 78.3 %
Skipped: 2026-03-14T09:30:10Z,TANK-1 (not enough values to unpack (expected 4, got 2))
Skipped: 2026-03-14T09:30:10Z,CABIN,ERR,kPa (could not convert string to float: 'ERR')
09:30:10 ENG-2: 415.0 C
Skipped: 2026-03-14T09:30:15Z,ENG-2,4l7.9,C (could not convert string to float: '4l7.9')
09:30:15 CABIN: 101.2 kPa
Parsed: 4, skipped: 3

Use except ValueError as error:; inside an f-string, {error} shows the message.

Print why each line was skipped
One try for both problems
You're not logged in, so your progress is kept in this browser only. Log in to save it, and to use hints and solutions.

Hints

script.py
PythonLn 1, Col 1Spaces: 4
Loading the Python environment…

Separate arguments with commas. They're passed on every Run as sys.argv[1:].