Scenario:
You are given a list of numbers:
numbers = [1, 2, 3, 4, 5, 6]
Question:
Write Python code to create a new list that contains:
1. Only the even numbers from the original list.
2. Each even number multiplied by 2.
Expected Output:
Answer:
even_doubled = [num * 2 for num in numbers if num % 2 == 0]
print(even_doubled)
Explanation:
⦁ The list comprehension iterates over each
num in numbers.⦁ The
if num % 2 == 0 condition filters to only even numbers (remainder 0 when divided by 2).⦁ For those,
num * 2 doubles them, building the new list concisely.