0

So I was trying to make an even or odd detector as i'm very new to programming but I stumbled upon a roadblock. The problem is that my detector says detects the number even no matter the input but this is only when I am comparing the number to multiple other numbers using "or '2' or '4' or '6' or '8'"

As soon as I remove the or's and only have one number to compare x to, it works perfectly fine

I have tried to solve this issue for about half an hour but I can't find anything wrong, so can someone help me please


def EvenOrOdd(item):
    x = list(str(item))
    if x[-1] == '0' or '2' or '4' or '6' or '8':
        print("Your number is even")
    else:
        print("Your number is odd")

Some dude
  • 1
  • 1

0 Answers0