Can someone help me with my code problem?

Write a function called check_values that has three parameters: x, y, and z. Every value passed to each of these parameters will be an integer. This function should return True if all three variables sum to a positive number or if at least two of the variables hold positive values. Otherwise this function should return False.

Below is my code:

def check_values(x, y, z):
    if x+y+z >= 0:
        return True
    elif (x or y >=0) or (y or z >=0) or (x or z >= 0):
        return True
        return False
    x = int(input('Enter X value: '))
    y = int(input('Enter Y value: '))
    Z = int(input('Enter Z value: '))

I failed this assert check:

assert not check_values(1, -1, -1), "this should return False, not True (or any other value)"

How do I fix this? Also is there a better way to do the check "if at least two of the variables hold positive values"?

>Solution :

The elif statement does not work this way.
You should write:
elif (x>=0 and y>=0) or ...:

Does this help?

Leave a Reply