Coding Quiz - Determine Odd/Even
In this quiz, you will write a function using the while
loop and lists to determine whether each number in a given list of integers is odd or even. Based on this, the function should return a new list with the strings "Odd"
or "Even"
based on the results.
The solution
function iterates over each element in the input list and adds "Odd"
if the element is odd or "Even"
if the element is even to a new list, and then returns it.
Parameter Format
def solution(numbers):
# Write your code here
return
Constraints
-
The input list contains only integers.
-
The list is not empty and contains at least one element.
Example
-
Input:
[1, 2, 3, 4, 5]
-
Output:
["Odd", "Even", "Odd", "Even", "Odd"]
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.