Practice: Basic Error Understanding

« Read the chapter

Q21. Input validator

IntermediateApplication

Write a function parse_age(text) that returns the integer if text is a whole number, otherwise returns -1. Print parse_age("25") and parse_age("x").

Goal: Validate input.