๐Ÿ PyQuest๐Ÿค” Making Decisions ยท ๐Ÿ”Ž Hunting Inside Words
โญ 0 XP๐Ÿ Python is waking upโ€ฆ

Hunting Inside Words ๐Ÿ”Ž

The word in asks: is this hiding inside that? It answers True or False, just like your other comparisons.

print("berry" in "strawberry")   # โžœ True
print("z" in "pizza")            # โžœ True
print("cat" in "dog")            # โžœ False

It works on whole sentences too, which makes it perfect for if:

message = "meet me at the treehouse"

if "treehouse" in message:
    print("Secret location detected! ๐ŸŒณ")

โš ๏ธ Careful โ€” in is fussy about capital letters. "Berry" in "strawberry" is False, because the big B doesn't match the little b.

Your mission

Build a snack detector!

  1. Make a variable message and store any sentence you like in it
  2. Use if with in to check whether message contains the word "snack" โ€” print a reaction if it does
  3. Add an else with a different reaction
  4. At the end, print one direct check on its own, like print("berry" in "strawberry"), so you can see the True or False

Your code

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