Python Practice › Loop Programs › Program 76
Copy even numbers to a new list
Write a Python program to copy the even numbers from a list into an empty list.
Input
[2, 3, 5, 76, 9, 0, 16]
Output
[2, 76, 0, 16]
Approach
- Append numbers with remainder 0.
Solution
a = [2, 3, 5, 76, 9, 0, 16]b = []for n in a: if n % 2 == 0: b.append(n)print(b)Output
[2, 76, 0, 16]
Learn the concept
New to this topic? Read the lesson, then come back.