Uploaded December 2022 | Updated September 2026, 2 weeks ago
This is a great and easy way to do simple filtering and mapping of lists with a minimal amount of code in Python. List comprehension is often also faster than using a for loop.
---
Code in Video
---
numberList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
evenList, oddList = [x for x in numberList if x % 2 == 0],[
x for x in numberList if x % 2 != 0]
print(evenList)
print(oddList)
---
Check out my channel for more!
This is a great and easy way to do simple filtering and mapping of lists with a minimal amount of code in Python. List comprehension is often also faster than using a for loop.
---
Code in Video
---
numberList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
evenList, oddList = [x for x in numberList if x % 2 == 0],[
x for x in numberList if x % 2 != 0]
print(evenList)
print(oddList)
---
Check out my channel for more!










