Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I keep getting the answer of not even or odd regardless of which numbers I enter in this program def is_list_even(my_list): x = 0 while

I keep getting the answer of not even or odd regardless of which numbers I enter in this program

def is_list_even(my_list):

x = 0

while x < len(my_list):

if x % 2 != 0:

return False

x= x + 1

return True

def is_list_odd(my_list):

x = 0

while x < len(my_list):

if x % 2 == 0:

return False

x = x + 1

return True

if __name__ == '__main__':

num_Vals = int(input())

input_list = []

for x in range(num_Vals):

input_list.append(num_Vals)

if is_list_even(input_list):

print('all even')

elif is_list_odd(input_list):

print('all odd')

else:

print('not even or odd')

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

Step: 3

blur-text-image

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

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions