Signup Input Validation
Write validate_signup(username, age) that raises a ValueError with a clear message if the username is empty or over 50 characters, or if age is not a non-negative integer under 150.
Input: Two lines: a username, and an age (as an integer).
Output: One line: "Valid signup" if both pass validation, otherwise "Error: <message>".
aditi 25
Valid signup
- age parses as an integer
Hint 1
Check the username condition first: `if not username or len(username) > 50:`
Hint 2
Check the age condition next: `if not isinstance(age, int) or age < 0 or age > 150:`
Hint 3
Each raised ValueError's message becomes the text printed after "Error: ".
validate_signup checks the username first (empty or over 50 characters both raise "Invalid username"), then the age (not an int, negative, or over 150 all raise "Invalid age"). The calling code's try/except prints "Valid signup" only when neither check raises, otherwise it prints the specific ValueError's message.