Kodewick
Start learning →
Starter←→0 / 80

Theme park age

#047StarterErrors3 min

The theme park kiosk asks kids for their age, but some type "twelve" or nothing at all. Write parse_age(text): if it turns into a whole number, return that number; if not, return None.

Examples
parse_age("12")→12
parse_age("twelve")→None
main.py
def parse_age(text):
    try:
        # your code here: turn text into an int and return it
        pass
    except ValueError:
        return None
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.