Amy
Amy

Reputation: 129

TypeError: must be real number, not str

Whenever I rum the code, error message "TypeError: must be real number, not str" displays

from math import*

num1 = input("Enter the num ")
num2 = input("Enter the power ")

def exponent_func( num1 ,  num2):
     return(pow ( str(num1) , str(num2) ))  

exponent_func(num1 ,  num2)

Upvotes: 7

Views: 87405

Answers (2)

You want to make the string inputs into floats or ints.num1 = float(num1)

Upvotes: 0

maxm
maxm

Reputation: 3667

Use int not str

from math import*

num1 = input("Enter the num ")
num2 = input("Enter the power ")

def exponent_func( num1 ,  num2):
     return(pow ( int(num1) , int(num2) ))  

exponent_func(num1 ,  num2)

Upvotes: 9

Related Questions