Space Python Loading Python…

Skip blanks and comments

Write the codeMedium 2 stages

The parser from "Parse the whole feed" works on clean data. The ground station's real export isn't clean: it has a comment at the top, blank lines between blocks, notes from the operators, and now and then a reading that arrived cut off.

Teach the parser to skip what it can't use and to keep going when a line is damaged.

The parser from "Parse the whole feed" stops with a ValueError on the first comment line. Skip blank lines and comment lines, so it prints only the readings:

09:30:05 ENG-2: 412.5 C
09:30:05 TANK-1: 78.3 %
09:30:10 CABIN: 101.2 kPa
09:30:10 ENG-2: 415.0 C

At the top of the loop, strip the line, then continue when it's empty or starts with #. Stripping first matters: one comment is indented, and a line can hold nothing but spaces.

Skip blanks and comments
Works for any export

Finish stage 1 to unlock this stage.

A reading arrived cut off: 2026-03-14T09:30:10Z,TANK-1 has only two fields, and the parser stops at it. Report damaged lines and carry on, then count what happened:

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 CABIN: 101.2 kPa
09:30:10 ENG-2: 415.0 C
Parsed: 4, damaged: 1

Split into fields first, and when len(fields) != 4, print the line, count it and continue. Count the parsed lines too, and print the totals after the loop.

Report damaged lines
Works for any export
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

Break and Continue in Loops

break-continue-loops.py
# break stops the loop the instant it runs
readings = [12, 45, 88, 210, 350, 190]
for value in readings:
    print("Checking flux:", value)
    if value > 200:
        print("Flare detected. Scan stopped.")
        break

# continue skips the rest of this pass and jumps to the next one
samples = [3.4, -1, 5.8, -1, 7.2]
total = 0
good = 0
for sample in samples:
    if sample == -1:
        print("Dropout, skipping this one")
        continue
    total = total + sample
    good = good + 1
print("Averaged", good, "good samples:", round(total / good, 2))

# while True runs forever on purpose, and break is the only way out
frequency = 1420
while True:
    print("Listening at", frequency, "MHz")
    frequency = frequency + 5
    if frequency > 1435:
        print("Band swept. Receiver off.")
        break
Open the full example
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:].