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.

Ryan McGuire
3,757 PointsDid I use the wrong arguments or is there something wrong with my return line 8
Did I use the wrong arguments or is there something wrong with my return line 8
import re
def first_number(numbers):
return re.search(r'\d',numbers)
def numbers(count,string):
return re.search(r'"\w"*count',string)
2 Answers

Steven Parker
221,310 PointsYou need to remove the extra set of quotes that enclose the word "count" for it to be recognized as a variable name. Also, since the function should be looking for numbers, you'll want to use "\d" instead of "\w" for the character class.
You could also create a recurrence constraint by adding a value and perhaps a comma between curly braces ({}
). And for that method you may want to build up the regex string using formatting or concatenation.

kgoldthorpe
7,802 PointsYou don't need the extra ' ' around "\w"*count and the \w is still a \d like from the first challenge.
a passing example below:
import re
def first_number(string_argument): return re.search(r"\d", string_argument)
def numbers(count_int, count_str): return re.search(r"\d" * count_int, count_str)