Patil has just started his first day at ABC Labs. As a beginner, he is assigned the task to check if the customer input for age is a valid number. He is given a list containing the age of different customers.
Help Patil write a program to filter and process the correct age into a new list.
Instructions
- Check if the given age is an
int
using type()
.
- If it is add it to the new list
verified_age
.
- If it is not, check whether the age is a string.
- If it is a string, check if the string is a valid number by using
isdigit()
.
- If it is a valid number, convert it to a number using
int()
and store it back in the list.
- If the value is not a string or a valid number, then ignore the value.