Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

=+ Why have these changes occurred?

Answered: 1 week ago

Question

=+90 percent of all oil refineries) into several smaller companies

Answered: 1 week ago