Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesPython FoundationsModule 4 · Object-oriented programmingFilter: only couplesscenario62 / 174
+100 XP
Task
📝 **Task:** From `numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]` keep only evens via list comprehension. 📋 Use `[n for n in numbers if n % 2 == 0]`. 💡 **Similar example (filter odds):** ```python nums = [10, 11, 12, 13, 14, 15] odds = [n for n in nums if n % 2 == 1] print(odds) # [11, 13, 15] ``` 🎯 **Expected output:** `[2, 4, 6, 8, 10]`
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
📊 Result
Press Run to see result...

💬 Discussion

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