I'm new to Python and after going through an example using a function to raise a number to a specific exponent, I tried to have it as the user for the numbers instead of just inputting them into the code.
Below is what I have:
def raise_to_power(base_num, pow_num):
int(base_num)
int(pow_num)
result = 1
for index in range(pow_num):
result = result * base_num2
return result
base_num = input("What number would you
like to exponentially raise?: ")
pow_num = input("To what power?: ")
print(raise_to_power(base_num, pow_num))`
When I try to run it though, I get the error listed below:
Traceback (most recent call last):
File "C:/Users/PycharmProjects/Exponent
Function.py", line 17, in <module>
print(raise_to_power(base_num, pow_num))
File "C:/Users/PycharmProjects/Exponent
Function.py", line 7, in raise_to_power
for index in range(pow_num):
TypeError: 'str' object cannot be
interpreted as an integer
Could someone explain why this might be happening?
Thank you,