samedi 29 mai 2021

Why the if statement continuing while the first condition is true

I have this program where a user will give 3 inputs. Comparing the inputs the program will return the biggest number. When a user give an input where the third number greater than the second number but the first number is the biggest number it gives a result that the third number is the biggest. But it should give the result that the first number is the biggest.

def max_num(x,y,z):
    x = input("num_1")
    y = input("num_2")
    z = input("num_3")
    
    if x > y and x > z:
        return(x + "is the biggest number")
    elif y > x and y > z:
        return(y + " is the biggest number")
    else:
        return(z + " is the biggest number")
        
        
print(max_num("num_1", "num_2", "num_3"))   

enter image description here

Aucun commentaire:

Enregistrer un commentaire