-5

I don't understand, why is foo() returning None?

def foo(a,b):
    if a+b == 12:
        return True
print(foo(7,5)) # Works fine
print(foo(1,3)) # prints None
Mabe
  • 29
  • 1
  • 3

1 Answers1

-4

You should return another bool if a+b is not 12

def foo(a,b):
    if a+b == 12:
        return True
    else:
        return False
answer1 = foo(1,3)
answer2 = foo(7,5)
if answer1:
    print "1 + 3 = 12"
if answer2:
    print "7 + 5 = 12"

foo() will return True if a+b == 12, if not should return False

Some Guy
  • 378
  • 1
  • 6