I can't figure out why this returns none!
I have a return for every branch...
Thanks in advance.
def recurPowerNew(base, exp):
'''
base: int or float.
exp: int >= 0
returns: int or float; base^exp
'''
if exp<=0:
return 1
elif exp%2==0:
return recurPowerNew(base*base, (exp/2))
return base*recurPowerNew(base, (exp-1))
print recurPowerNew(7.62,9)
if/elif/else, instead ofif/elifand then falling off the end of that statement. (That would also have made your actual bug impossible to write.)returnfor every branch. You have tworeturns for the second branch, and none for the third...