← Back to challenges

Find the Bug: Returning the Container

PythonMediumbugscontrol_flowconditionslogic

Instructions

The packaging system is running wild! The candy is lying loose all over in the warehouse, the cereal is missing, and bread is stuffed in a bottle. What is going on here? The candy should be in plastic and the bread should be in a bag.

The packaging machine is running the get_container() function to retrieve the container of a product. But something is not right...

Examples

get_container("Bread") ➞ "bag"

get_container("Beer") ➞ "bottle"

get_container("Candy") ➞ "plastic"

get_container("Cheese") ➞ None

Notes

Think about what the object's packaging should be.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Binary Addition + 0 1 0 1