Space Python Loading Python…

Break and Continue in Loops

 
0:00 / 0:00

Challenge

Practise what this example shows with these challenges.

Skip blanks and comments

Write the codeMedium 2 stages

Extend the feed parser so continue skips blank lines and comment lines, then report damaged lines with too few fields instead of crashing, with a count of parsed and damaged lines.

Start the challenge

First error

Write the codeEasy 2 stages

Scan the mission log for the first ERROR entry, print its line number with enumerate() and stop there with break, then report how many lines were checked, or that there were no errors at all.

Start the challenge

Retry the uplink

Write the codeMedium 2 stages

Send a command up to three times, taking each result from a list of simulated radio replies, and stop at the first success with break; then wait 2, 4, 8 seconds between attempts, as real retry code does.

Start the challenge

Discussion

Stuck on this example or want to go further? Ask here, or see what others asked.

Log in to ask and reply.

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:].