Question: Write an iterative function (in Python) all_odd(L) that takes an input list, L, and returns True if all integers in L are odd, and False

Write an iterative function (in Python)

all_odd(L) 

that takes an input list, L, and returns True if all integers in L are odd, and False otherwise. Here are some example inputs and expected outputs:

>>> all_odd([55, 6, 3, 4]) False >>> all_odd([9]) True >>> all_odd([3, 7, 99, 111]) True >>> all_odd([]) True 

Note that, based on the last sample input, an empty list has no integers, so we say that all integers in the list are odd.

Remember: You can use the modulus (%) operator to check if a number is odd. Specifically, a number, n, is odd if:

n % 2 == 1 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!