Coding Quiz - Extract Elements from List
In this Python coding quiz, you'll write a function that extracts elements from a list based on a specific condition using the filter
and map
functions, then applies a transformation to each extracted element.
The function below, named solution, should take a list of integers as input, extract only the odd numbers, and return a new list with each extracted odd number multiplied by 2.
Function Parameter Format
def solution(numbers):
# Write your code here
return
Constraints
-
The input list consists of integers.
-
The output list should contain the result of multiplying each odd element from the input list by 2.
Example Input and Output
-
Input:
[1, 2, 3, 4, 5]
-
Output:
[2, 6, 10]
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.