lundi 12 septembre 2016

if, else not working properly

I was solving python exercise on CodingBat.

But I got unexpected result. Here is my code:

def fix_teen(n):
    if n in range(13,20) and (n != 15 or n != 16):
        return 0
    return n

def no_teen_sum(a, b, c):
    return fix_teen(a) + fix_teen(b) + fix_teen(c)  

print no_teen_sum(2, 1, 15) 

As expecting, It should print 15 but it is printing 3. Not sure Why? Please help.

Aucun commentaire:

Enregistrer un commentaire