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

Evan Mnatsekanov
Evan Mnatsekanov
1,761 Points

What does this mean?

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

def numbers(fivenumbers):
    return(re.search(r'/d' * 5, fivenumbers))
#It says: numbers() takes 1 positional argument but 2 were given

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 68,029 Points

Hey Evan Mnatsekanov, the second task says "Now, write a function named numbers() that takes two arguments: a count as an integer and a string.". Your function numbers() only takes one argument. When the task checker runs, it provides two arguments, but only one is allowed by your code. This causes the error that you see.

It is your function that is not accepting the second argument. Please updated your numbers() function to accept a count as well as a string as the two arguments.

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

Chris Freeman
Chris Freeman
Treehouse Moderator 68,029 Points

In three steps:

  • add a count parameter to the function signature line:
def numbers(count, fivenumbers):
  • use the count to define the repeated number
    return(re.search(r'\d' * count, fivenumbers))
  • notice that the typo / has been replaced with **

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