Back to Practice
#0165
Normalize Phone Digits
EasyPython15 min10 XP
Problem
Given a phone-like string, return only its digits in their original order.
Why This Matters
Text cleaning is often the difference between clean joins and broken customer/user matching.
Function Signature
def phone_digits(text):
Examples
Example 1
Input"+91 (987) 654-3210"
Output"919876543210"
Symbols, spaces, and parentheses are removed; digit order is preserved.
Constraints
- Return the exact requested output.
- Handle ordinary edge cases.
- Prefer simple, interview-readable code.
CodePython
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core example
Input"+91 (987) 654-3210"
Expected"919876543210"
Symbols, spaces, and parentheses are removed; digit order is preserved.
Hidden Test Categories
empty or minimal inputduplicates or tieslarger input