We cannot raise a string of digits to a power unless we convert it manually to an integer:
while True: reply = input('Enter text:') if reply == 'stop': break # ww w . ja v a 2 s . c o m elif not reply.isdigit(): print('Bad!') else: print(int(reply) ** 2) print('Bye')