Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am trying to code if three numbers are even, odd, or neither (when the numbers have an even AND odd in the input). I'm just stuck since every time it outputs "odd" no matter the numbers. Here's my code so far:

msg = input("Enter a,b,c: ")

nums = msg.split(',')

a = int(nums[0])

b = int(nums[1])

c = int(nums[2])

if (a, b, c % 2) == 0:

    print("even")

else:

    print("odd")

I think I should use tuples but I don't know how to incorporate it. 

1 Answer

0 votes
by (36.8k points)

I think your professor meant something like this:

if (a % 2, b % 2, c % 2) == (0, 0, 0):

 If you want to know more about the Data Science then do check out the following Data Science which will help you in understanding Data Science from scratch

Browse Categories

...