Code

Is It In There?

in checks whether one string appears inside another. not in checks the opposite:

note = "Beware the glass bridge"
print("glass" in note)     # True
print("Glass" in note)     # False – case matters!
print("gold" not in note)  # True

Use .lower() first when case shouldn't matter: "glass" in note.lower().

Checking for None

None means "no value". To check for it, use is None (or is not None), not ==:

keeper = None
if keeper is None:
    print("No keeper yet")

is asks "is this the very same object?" There is only one None in all of Python. So is None is exact, and it's the officially recommended style.

Always check for None before calling methods on a value. None.lower() crashes with an AttributeError.

Assignment

Complete check_crate(label). label is a string, or None when the crate has no label:

  1. If label is None, return "unlabelled".
  2. If "fragile" appears in the label (any capitals), return "handle with care".
  3. Otherwise return "ok".