Recap: Supply Run
Combine string methods, lists, looping over lists, and break/continue
Mission: Supply Run
The station receives a list of supply crates named items (already on the right). Some crates are contaminated: their name starts with con-. Sort the good supplies into a clean list with these rules:
- Loop through the items.
- Skip any crate whose first four characters are
con- - For every good crate, add it to a new list called
clean - The moment you add
butter, the bay is full, so stop right after adding it - Print each item in
clean, one per line - Print
Total:then how many items ended up inclean
Output
milk
bread
cheese
butter
Total: 4
The two con- crates are skipped, and the loop stops as soon as butter is added, so jam is never reached.