how to rethrow an exception in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to rethrow an exception in python

i am working on a gpa calculator and i'm using try and except to catch some errors but i don't know how to rerun the code after the exception is caught. How do you do this

5th Oct 2022, 7:38 AM
The boss
The boss - avatar
1 Answer
+ 3
put the code inside a while True loop? while True: try: print("Whats your name?") name = input("Name:") print(name) if name=="q": raise KeyboardInterrupt elif name=="exit": break except KeyboardInterrupt: print("error raised\ncontinue?\nEnter 'exit' to quit program")
5th Oct 2022, 8:16 AM
Bob_Li
Bob_Li - avatar