Created
August 13, 2025 08:18
-
-
Save gabri83/1a7930ee6f12f55b86284733a1bae2b3 to your computer and use it in GitHub Desktop.
Python: List Comprehension for Filtering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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