Python Control Flow
💡
Exercise 16

Sorting Hat 20 XP Medium

Ctrl+Enter Run Ctrl+S Save

In the Harry Potter series, the Sorting Hat assigns new students to one of four houses: Gryffindor, Hufflepuff, Ravenclaw, or Slytherin.

Let's build our own Sorting Hat using everything we've learned in this chapter!

We'll generate a random number and use if/elif/else to assign a house.

📋 Instructions
Create a Sorting Hat program: 1. Import `random` 2. Generate a random number between 1 and 4 3. Assign houses: - 1: Print `Gryffindor 🦁` - 2: Print `Hufflepuff 🦡` - 3: Print `Ravenclaw 🦅` - 4: Print `Slytherin 🐍` **Bonus**: Add a welcome message before the house!
Use random.randint(1, 4) and check each number to print the corresponding house.
main.py
Hi! I'm Rex 👋
Output
Ready. Press ▶ Run or Ctrl+Enter.