[Python] TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int' with Python3...

Discussão em 'Python' iniciado por Stack, Novembro 23, 2024.

  1. Stack

    Stack Membro Participativo

    My Python3 code

    def ask():

    while True:
    try:
    n = input('Input an integer: ')
    except:
    print ('An error occurred! Please try again!')
    continue
    else:
    break


    print ('Thank you, you number squared is: ', n**2)


    Why do I got error if I want to take a square of number?

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


    From command line no problems

    >>> 3**2
    9

    Continue reading...

Compartilhe esta Página