def is_either_even_and_less_than_9(num1, num2):
if (num1 and num2) > 9:
return False
if (num1 or num2) % 2 == 0:
return True
else:
return False
Asked
Active
Viewed 382 times
-3

CryptoFool
- 21,719
- 5
- 26
- 44

William Fuzzy
- 3
- 1
-
1What's the problem? – Frank Mar 03 '21 at 02:56
-
I see you're a new contributor. I think the problem here is simply a small mistake regarding boolean logic and python syntax. It is, however, good practice in Stack Overflow to search for some similar questions before asking one yourself! It may sound mean, but consider breaking your problem into smaller problems, which in turn probably have a question regarding them! Hope you enjoy the community. – eduardokapp Mar 03 '21 at 03:00
2 Answers
1
Your boolean logic syntax is wrong. You want:
def is_either_even_and_less_than_9(num1, num2):
if num1 >= 9 and num2 >= 9:
return False
if num1 % 2 == 0 or num2 % 2 == 0:
return True
else:
return False

CryptoFool
- 21,719
- 5
- 26
- 44
0
num1 and/or num2 will return num2 which is then compared.
It should be:
def is_either_even_and_less_than_9(num1, num2):
if num1 > 9 or num2 > 9:
return False
elif num1 % 2 == 0 or num2 % 2 == 0:
return True
else:
return False

Akash Rudra
- 136
- 1
- 2