๐Ÿ PyQuest๐Ÿค” Making Decisions ยท ๐Ÿฅ‡ elif: More Than Two Paths
โญ 0 XP๐Ÿ Python is waking upโ€ฆ

elif: More Than Two Paths ๐Ÿฅ‡

Sometimes there are more than two possibilities. elif (short for "else if") lets you chain as many checks as you want:

grade = 85

if grade >= 90:
    print("Grade: A โญ")
elif grade >= 80:
    print("Grade: B")
elif grade >= 70:
    print("Grade: C")
else:
    print("Let's practice some more!")

Here's the important part: Python reads the chain top to bottom, stops at the first check that's True, runs that one, and ignores everything below it. Only one message ever prints.

You can have as many elifs as you like. The else at the end catches everything that didn't match.

Your mission

Build a race medal announcer!

  1. Make a variable place with the number you finished in
  2. If place is 1, print a gold medal message ๐Ÿฅ‡
  3. Use elif for 2nd place ๐Ÿฅˆ and elif for 3rd place ๐Ÿฅ‰
  4. Finish with an else for everyone else

Your code

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