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
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")