mercredi 19 juillet 2017

nested if ... else (python exercise)

so im trying to build a function that checks which of a,b,c is less then returns the lesser value...

def minimal_three(a,b,c):
if a < b:
    if a < c:
        return (a)
elif b < a:
    if b < c:
        return (b)
elif c < a:
    if c < b:
        return (c)
else:
    return 'none'

so far the code runs fine until it gets to check 'c', then it doesnt return anything, nested if else statements already get really confusing to me , just asking for a little bit of help plz...

Aucun commentaire:

Enregistrer un commentaire