mardi 3 septembre 2019

Why is my code returning True instead of False? [duplicate]

This question already has an answer here:

I'm trying to make a small program for it to return True if one of the integers is 10 or if their sum is 10. Please see the code.

I've been trying to switch between 'or' or 'and'. But no luck

#Given 2 ints, a and b, return True if one if them is 10 or if their sum 
#is 10.

def makes10(a, b):
  if a or b == 10:
    return True
  elif a + b == 10:
    return True
  else:
    return False

print(makes10(9,10))
print(makes10(9,9))  #This one is not giving False.
print(makes10(1,9))    

I expect the output of print(makes10(9,9)) to be False

Aucun commentaire:

Enregistrer un commentaire