Skip to main content
← CoursesPython FoundationsModule 1 · Fundamentals of syntaxFizzBuzzwrite14 / 170
💬 Discuss🧪 Playground+100 XP
Task
📝 **Task:** Classic "FizzBuzz" challenge. For numbers 1 to 15 print: - "FizzBuzz" if the number divides by 15 - "Fizz" if it divides by 3 - "Buzz" if it divides by 5 - the number itself otherwise 📋 **Steps:** 1. Loop `for i in range(1, 16):` 2. Inside check divisibility with `%` 3. Check `i % 15 == 0` FIRST (otherwise Fizz catches it earlier) 4. Then `i % 3 == 0`, then `i % 5 == 0`, else `print(i)` 💡 **Simpler variant (even/odd):** ```python for i in range(1, 6): if i % 2 == 0: print("even") else: print("odd") ``` ⚠️ **Hint:** order matters! 15 divides by both 3 and 5 — if you check `i % 3` first, 15 would print "Fizz", not "FizzBuzz". 🎯 **Expected output (15 lines):** ``` 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz ```

Keep going

✏️ Write your code here
🐍
Loading Python...
First visit only — ~5-10s. Stays cached afterward.
📊 Result
Press Run to see result...
📣 Help someone learn PythonShare this lesson with a friend — the first 15 are free, no signup.Tweet

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…