Phone Number Validator
Write a function isvalidphone(number) that returns True if the input is exactly 10 digits, False otherwise.
Approach: anchor the pattern to both the start and end of the string with ^ and $ so partial matches don't count.
Input: One line: a phone number as text.
Output: One line: True or False.
9876543210
True
- 1 <= length <= 20
Hint 1
^\d{10}$ requires exactly 10 digits, from the very start to the very end of the string.
Hint 2
Without ^ and $, the pattern could match just a 10-digit substring inside a longer string — the anchors make sure the WHOLE string is exactly 10 digits.
^\d{10}$ anchors the digit-count check to the entire string: ^ pins it to the start, {10} requires exactly ten digits, and $ pins it to the end — so a string with extra characters before or after ten digits, or fewer than ten digits, won't match.