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 Escapes

Understanding the question

I don't really understand what the question is asking. I think that it's asking me to find count number of numbers in the string and print the re.search of the numbers that I find. Is this right and if so how do I do that. Do I need another for statement?

escapes.py
import re

def first_number( var ):
    return re.search(r'\d', var)

def numbers( count_, var_str):
    for _ in range(count_):
        return re.search(r'\d', var_str)

2 Answers

Rick Gleitz
Rick Gleitz
47,840 Points

You don't need the for statement, and the return just needs to have the r'\d' multiplied by the count_ parameter. It seems to be asking to find a continuous number of digits in the string. Hope this helps.

justlevy
justlevy
6,325 Points

The wording of this challenge was difficult to understand (Challenge 2/2, Regular Expressions, Escapes).