Else and Finally Timing
Both calls below run through the same validate function.
def validate(payload):
try:
print("checking payload")
if not payload.get("email"):
raise ValueError("missing email")
except ValueError as e:
print(f"rejected: {e}")
else:
print("payload accepted")
finally:
print("validation done")
validate({"email": "a@b.com"})
validate({})
What does this print, in order?
Sign in to answer questions and track your progress
Sign In