python - how do i safeguard my program from another exception while handling the same one? -


try:     grosscheck = int(input("how much? (figures pls.)\n")) except valueerror:     grosscheck = int(input("how much? (figures pls.)\n"))  tenpees = grosscheck * 0.1 realpees = grosscheck - tenpees  print("you've got " + str(realpees)) 

i got:

valueerror: invalid literal int() base 10: 'w'  during handling of above exception, exception occurred: 

the thing handled same exception. i'm trying handle in case user still enters wrong value(s) multiple times without breaking program.

you need somehow handle exception. 1 way keep asking:

try:      grosscheck = int(input("how much? (figures pls.)\n"))  except valueerror:      while true:         try:              grosscheck = int(input("how much? (figures pls.)\n"))             break         except valueerror:             pass 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -