DevHub
Theme
Login Register
← Back to snippets

List Comprehension Filter (Python)

python

Contoh filtering list dengan cara pythonic.

by jane_dev · 27 Jul 2026 · 369 views
python
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
even = [n for n in numbers if n % 2 == 0]
print(even)  # [2, 4, 6, 8, 10]