Skip to content

Instantly share code, notes, and snippets.

@gabri83
Created August 13, 2025 08:18
Show Gist options
  • Select an option

  • Save gabri83/1a7930ee6f12f55b86284733a1bae2b3 to your computer and use it in GitHub Desktop.

Select an option

Save gabri83/1a7930ee6f12f55b86284733a1bae2b3 to your computer and use it in GitHub Desktop.
Python: List Comprehension for Filtering
numbers = [1, 2, 3, 4, 5]
evens = [n for n in numbers if n % 2 == 0]
print(evens) # [2, 4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment