SolveWithPython

Challenge 5: Filter Even Numbers

You’ll filter values from a list based on a condition.
Estimated time: 10 minutes | Difficulty: Beginner

Problem

Return only the even numbers from a list.

Inputs

  • numbers: list[int]

Output

A list of even integers.

Example

Input

Python Challenge 5 Input Filter Even Numbers

Output

Python Challenge 5 Output Filter Even Numbers

Constraints

  • Input may be empty
  • The list may contain negative numbers
  • Zero (0) is considered even
  • Do not modify the original list

Requirements

  • Function name: filter_even
  • Parameter: numbers (list of integers)
  • Return type: list[int]

Starter Code

Python Challenge 5 Starter Code Filter Even Numbers

Edge Cases to Consider

  • Empty list
  • List with no even numbers
  • List containing zero
  • List containing negative numbers

Python Challenge 5 Solution Filter Even Numbers

Explanation

  • Iterate through the list and select numbers divisible by 2
  • Time complexity: O(n)
  • Space complexity: O(n)

Python Challenge 5 Test Filter Even Numbers

Nice work!

You’ve completed this challenge. The best way to improve your Python skills is to keep practicing while the concept is fresh.

What you’ve accomplished

By finishing Challenges 1–5, you’ve practiced:

  • Strings
  • Lists
  • Dictionaries
  • Conditions
  • Real validation with tests

This is a strong foundation.

🔗 View reference solution on GitHub
(After you’ve tried the challenge)

👉 Next Challenge → Even or Odd (With Input Validation)

Want more practical Python challenges?
Subscribe to the Solve With Python newsletter and get new problems delivered to your inbox.