close

[Solved] TypeError: must be real number, not str

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error TypeError: must be real number, not str in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How TypeError: must be real number, not str Error Occurs?

Today I get the following error TypeError: must be real number, not str in python.

How To Solve TypeError: must be real number, not str Error ?

  1. How To Solve TypeError: must be real number, not str Error ?

    To Solve TypeError: must be real number, not str Error You want to make the string inputs into floats or ints.num1 = float(num1)

  2. TypeError: must be real number, not str

    To Solve TypeError: must be real number, not str Error You want to make the string inputs into floats or ints.num1 = float(num1)

Solution 1


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)

Solution 2

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

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read