Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Regular Expressions in Python Introduction to Regular Expressions Escapes

Stheven Cabral
.a{fill-rule:evenodd;}techdegree seal-36
Stheven Cabral
Full Stack JavaScript Techdegree Graduate 29,841 Points

Confused with "count numbers in the string"

In challenge task 2 of 2, what is the question asking for when it says "return an re.search for exactly count numbers in the string"? I'm not to sure what the question is asking me to do.

import re

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

def numbers(integ, strg):
    return re.search(r'integ', strg)

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 68,227 Points

The question is asking to create a function that takes some integer count and a string. Check to see if there are any number sequences of count digits long. Digits can be test for using \d.

For example, given the input 3 and "this89string123has1stringof3characters", the function should return a search result of "123"

Post back if you need more help. Good Luck!!