Find All 10-Digit Phone Numbers

Easy ⏱ 8 min 87% acceptance ★★★★★ 4.5
Write phones(text) returning every standalone 10-digit number in the text using re.findall with word boundaries — \b\d{10}\b — so 11-digit runs don't match.

Examples

Example 1
Input
phones('call 9876543210 or 9123456780, not 123')
Output
['9876543210', '9123456780']
Explanation

Two exact-10-digit tokens.

Constraints

  • Use re.findall.
  • Exactly 10 digits, bounded.

Topics

Regular Expressionsfindall

Companies

TCSInfosysAirtel Digital

Hints

Hint 1

\b marks word boundaries.

Hint 2

{10} is the repetition count.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.