aliweb aliweb - 5 months ago 16x
Python Question

Find the maximum of three numbers in python

What is my problem? I run

but it returns nothing.

def biggest(a,y,z):
if y>Max:
if z>Max:
return Max

aga aga

It's because of indentation in your function. You've put the instruction return Max on the most inner level of your chain of if's, so it returns result only if the maximum is z number. When the a or y is maximum it returns nothing. You can read more about python's attitude to indentation here.

def biggest(a, y, z):
    Max = a
    if y > Max:
        Max = y    
    if z > Max:
        Max = z
        if y > z:
            Max = y
    return Max

If you don't need to implement your own function, you can use built-in max function, as Mingyu pointed out.