I am trying to figure out why I am not getting the correct answer for this coding in python. Here is my code so far:
def main():
base = input('Enter an integer for the base: ')
exponent = input('Enter an integer for the exponent: ')
print(base,'to the power', exponent,'equals', power)
def power(base, exponent):
if exponent <= 1:
return base
else:
return base * power(base, exponent - 1)
main()
When I run the program with a 2 and 5 (base, exponent) I get this:
Enter an integer for the base: 2
Enter an integer for the exponent: 5
2 to the power 5 equals <function power at 0x03DDC300>
>>>
My question is this: Why am I getting "function power at 0x03DDC300" or similar answers instead of the correct answer of 32?