Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Regular Expressions in Python Introduction to Regular Expressions Phone Numbers

what is the solution to code challenge one in regular expressions

what is the problem with the code??

phone_number.py
import re
def phone_numbers( a):
    return re.findall(r"555-555-5555",a) 

2 Answers

Steven Parker
Steven Parker
231,269 Points

The phone number will all be in the format of the example number, but they won't all be that same number.

:point_right: In your regex, "5" only represents 5. To represent any digit, use the code "\d".

Kyler Smith
Kyler Smith
10,110 Points

You're so close! The format is for them to be in is "555-555-5555". So this could be any combination of numbers, but in this format. For example, you could be looking for "123-456-7890" or "098-765-4321". Your regular expression is only looking for the values "555-555-5555". To fix this, you need to check for any combination of numbers. (Try using the \d regEx)! Good luck!