promptdojo_

Write a function validate_age(age) that:

  • Returns age unchanged when age is an integer between 0 and 120 (inclusive).
  • Raises ValueError with the message f"age out of range: {age}" otherwise.

Then call it three times inside try/except ValueError as err: print(err) blocks so the output below prints. Use print(validate_age(...)) for the happy-path call.

Expected output:

30
age out of range: -5
age out of range: 200

this step needs the editor

on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.

open this same url on a laptop to keep going today.