Print the manifest
In "Manifest line" you printed one item from a tuple. The logistics system now exports the whole manifest as a list of dicts, one per item, with an ID, a name, a category and a mass. The loading crew wants it printed, one line per item, with the total at the bottom.
Finish stage 1 to unlock this stage.
Print one manifest line for every item, with the mass to one decimal place:
CG-0042 | Water filter cartridges | 18.5 kg CG-0043 | Spare cabin fan | 2.4 kg CG-0044 | Freeze-dried meals | 42.0 kg CG-0045 | CO2 scrubber cartridges | 31.3 kg CG-0046 | Tablet computers | 3.4 kg CG-0047 | Rice and lentils | 25.0 kg
Loop over cargo; each record is a dict, so record["id"], record["item"] and record["mass_kg"] give its fields.
Finish stage 1 to unlock this stage.
Add up the masses in the same loop and print a total line at the bottom:
CG-0042 | Water filter cartridges | 18.5 kg CG-0043 | Spare cabin fan | 2.4 kg CG-0044 | Freeze-dried meals | 42.0 kg CG-0045 | CO2 scrubber cartridges | 31.3 kg CG-0046 | Tablet computers | 3.4 kg CG-0047 | Rice and lentils | 25.0 kg Total: 122.6 kg in 6 items
Start total_kg = 0 before the loop and add record["mass_kg"] to it inside.
Hints
Iterating Over Dictionary
# 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")
Separate arguments with commas. They're passed on every Run as sys.argv[1:].