1

When I run this code everything works as intended until the last line where I get the following error:

TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'str'

If I'm understanding this correctly X and Y are being recognized as strings (literally the letters X and Y). Not the variables representing the integer the user input. So how do I get Python to see the user input and not the string? My apologies for asking something so basic but I've searched around and haven't found an answer, or at least not one I understand.

print("Hello!")
x = input("Please enter the number to be raised:")
print("Confirmed.  We are going to raise", x)
y = input("Please enter the power you want it raised to:")
print("Confirmed.  Raising", x, "to the power of", y)
print (x**y)
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Hezakai
  • 35
  • 4

0 Answers0