I am trying to create a method which returns the value of three variables added together, with a further condition that that if one of the variables is 13, 14, or between the range 17 -19 inclusive, this particular variable should then count as 0 in the final sum.
I am trying to define a further method to check each number individually so have to write out the same code three times in one method.
My code so far is as follows:
def no_teen_sum(a, b, c):
fix_teen(a)
fix_teen(b)
fix_teen(c)
return a + b + c
def fix_teen(n):
if (n == 13 or n == 14) or (n >= 17 and n <= 19):
n = 0
return n
print(no_teen_sum(1, 2, 13))
The code is failing to get back the required results and is just adding together a, b and c with no regard for the conditions I have mentioned above. I had thought that calling the checking method 'fix_teen' within the overall method 'no_teen_sum' would combat this but clearly it is being ignored by Python.
How do I achieve what I need to here?