I am trying to take two values as parameters and return True if its value is equal to 10 and false if it isn't. The values are strictly int. Here is the code
class Solution:
def twomakes10(self, no1, no2):
if sum(no1, no2) == 10:
return True
else:
return False
if __name__ == "__main__":
p = Solution()
n1 = 9
n2 = 1
print(p.twomakes10(n1, n2))
sum()function applies to sequences - lists, tuples, etc. Simply adding two numbers is writtenno1 + no2.sum()should be an iterable. See doc. You can simply doif no1 + no2 == 10:if ... elseto transform a boolean into a boolean. Your 4-line definition fortwomakes10can be replaced by the single linereturn no1+no2 == 10