Space Python Loading Python…

Approved payloads

Write the codeEasy 2 stages

Nothing goes into Python One's cargo bay unless the safety board has approved it. The board keeps a list of approved payload IDs, and the loading crew checks every item against it before it goes aboard.

Check an ID against the list, then make the check work for IDs typed by hand.

Print whether the payload is on the approved list:

PL-204 approved: True

payload_id in approved gives True or False.

Check the list
Only exact IDs pass

Finish stage 1 to unlock this stage.

The loading crew types IDs by hand, with small letters and stray spaces. The starter code says False for " pl-117 ", although PL-117 is approved. Clean the ID first, then print a clear message:

PL-117: cleared for loading
PL-999: not on the approved list

Strip the spaces and make it upper case, then use if with in. For " pl-117 " it prints the first line.

Accept a typed ID
Right for any ID
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

Creating Lists

creating-lists-python.py
# Lists - ordered collections of items

# Square brackets, items separated by commas
planets = ["Mercury", "Venus", "Earth", "Mars"]
print("Inner planets:", planets)

# One list can hold different types at once
mission = ["Hail Mary", 3, True, 11.9]
print("Mission record:", mission)

# An empty list is still a list, ready to be filled later
sample_tubes = []
print("Samples collected:", sample_tubes)

# len() counts the items
crew = ["Grace", "Yao", "Ilyukhina"]
print("Crew size:", len(crew))
print("Tubes filled:", len(sample_tubes))

# The in operator checks membership
candidate_stars = ["Tau Ceti", "Epsilon Eridani", "Wolf 359", "Sirius"]
print("Stars checked:", len(candidate_stars))

if "Tau Ceti" in candidate_stars:
    print("Tau Ceti is on the target list")

if "Betelgeuse" not in candidate_stars:
    print("Betelgeuse is too far to bother")
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:].