Practice: Basic Error Understanding
Q21. Input validator
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.
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.