To support input of floating-point numbers instead of just integers, run a float call and catch its exceptions:
while True: reply = input('Enter text:') if reply == 'stop': break try: # ww w . j a v a 2s . c o m print(float(reply) ** 2) except: print('Bad!' * 8) print('Bye')