Question
Write a function that takes in a list of integers and returns a list containing either all the odd numbers or all the even numbers
Write a function that takes in a list of integers and returns a list containing either all the odd numbers or all the even numbers in the list. The function should have two parameters: the list of integers, and a string (either odd or even) that determines if the function should return all the odds or all the evens. If a user does not pass in a second argument (the string even or odd), the function should default to returning all evens.
If there is something in the list that is not an integer, raise a ValueError and tell the user that this function can only take in lists of integers.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started