๐Ÿ PyQuest๐Ÿงบ Lists & Collections ยท ๐Ÿ” Is It In There?
โญ 0 XP๐Ÿ Python is waking upโ€ฆ

Is It In There? ๐Ÿ”

Python has a magic word for searching a list: in.

It answers a yes-or-no question โ€” "is this thing inside that list?" โ€” which makes it perfect for an if:

squad = ["Ana", "Bo", "Cy"]

if "Bo" in squad:
    print("Bo is here! ๐ŸŽ‰")
else:
    print("No Bo today...")

You can search with a variable too:

visitor = "Cy"
if visitor in squad:
    print("Come on in!")

It even works on strings โ€” if "z" in name: checks for a letter inside a word!

Your mission

Build a party door checker.

  1. Make a list called guest_list with at least 5 names
  2. Make a variable called visitor holding one name
  3. Use if / else with in to print whether they're welcome
  4. Both messages should include the visitor's name (f-string time!)

Then try it: change visitor to someone NOT on the list and run again. ๐Ÿšช

Your code

Press โ–ถ Run to see what your code does!