Manifest line
Every item in the cargo manifest is stored as a tuple: its ID, what it is and its mass. The loading report shows one line per item, with the fields in a fixed layout the crew knows by heart.
Unpack an item and print its line, then cope with the manifest gaining a new field.
Finish stage 1 to unlock this stage.
Unpack the tuple into three variables and print one manifest line, with the mass to one decimal place:
CG-0042 | Water filter cartridges | 18.5 kg
Three names on the left of =, one for each value, in order.
Finish stage 1 to unlock this stage.
The manifest now also records the module each item is stowed in. The starter code stops with ValueError: too many values to unpack, because the tuple has four values and only three names. Fix the unpacking and add the module to the line:
CG-0042 | Water filter cartridges | 18.5 kg | Node 2
Hints
Tuple Unpacking
# Tuple unpacking: one line, many variables
# New Horizons flyby of Pluto, 14 July 2015
flyby = ("New Horizons", "Pluto", 12472)
probe, target, closest_km = flyby
print(f"{probe} passed {target} at {closest_km} km")
# Asterisk grabs everything that is left over
ares3 = ("Lewis", "Johanssen", "Martinez", "Vogel", "Beck", "Watney")
commander, *crew, botanist = ares3
print("Commander:", commander)
print("Crew:", crew)
print("Left behind on Mars:", botanist)
# Swapping two values without a temporary variable
primary_dish, backup_dish = "Goldstone", "Canberra"
primary_dish, backup_dish = backup_dish, primary_dish
print(f"Now transmitting from {primary_dish}, backup is {backup_dish}")
# Underscore marks a value you do not need
sample = ("Ryugu", 2020, 5.4)
asteroid, _, grams = sample
print(f"Hayabusa2 returned {grams} grams of {asteroid}")
# Unpacking inside a for loop
moons = [("Titan", 5150), ("Enceladus", 504), ("Iapetus", 1469)]
for name, diameter_km in moons:
print(f"{name}: {diameter_km} km across")
Separate arguments with commas. They're passed on every Run as sys.argv[1:].