Space Python Loading Python…

Go launches only

Write the codeEasy 2 stages

The launch list from the API mixes launches that are cleared to fly with ones still waiting for a date, a payload or the weather. The public board highlights only the launches that are Go.

Filter the list by status, then add a line for everything that is still waiting.

Print only the launches whose status is Go, with their provider:

Lumen-3 (JAXA)
Tern-5 (ISRO)
Aurora Relay 2 (JAXA)

Loop over the launches and compare launch["status"] with "Go".

Show the Go launches
Works for any list

Finish stage 1 to unlock this stage.

Collect the launches that aren't Go, each with its status, and print them on one line after the Go launches, or none:

Lumen-3 (JAXA)
Tern-5 (ISRO)
Aurora Relay 2 (JAXA)
Not go yet: Kestrel-7 (TBD), Polaris Cargo 4 (Hold)

Build a list in the else branch, then join it after the loop.

List the waiting launches
Works for any list
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

Iterating Over Dictionary

iterating-over-dictionary.py
# How long a single day lasts on each planet, measured in Earth hours
day_hours = {
    "Mercury": 1408,
    "Venus": 5832,
    "Earth": 24,
    "Mars": 24.6,
    "Jupiter": 9.9,
}

# A plain for loop walks the keys
for planet in day_hours:
    print("Planet:", planet)

# .values() walks the values instead
total = 0
for hours in day_hours.values():
    total = total + hours
print("All five days added together:", total, "hours")

# .items() hands you the key and the value at the same time
for planet, hours in day_hours.items():
    print(f"{planet}: one day is {round(hours / 24, 2)} Earth days")

# sorted() walks the same keys in a different order
for planet in sorted(day_hours):
    print(planet, "->", day_hours[planet], "hours")
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:].