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 Players Dictionary and Class

Can't pass the challenge and not sure why

The last line of plays is giving me trouble and I am not sure how to tackle it

import re

string = '''Love, Kenneth: 20
Chalkley, Andrew: 25
McFarland, Dave: 10
Kesten, Joy: 22
Stewart Pinchback, Pinckney Benton: 18'''

players = re.search(r'''
                    , string, re.X|re.M)

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 68,166 Points

You're on the right track. A few items to correct

  • The "multiple repeat" error is due to the "+*". This says "zero or more of one or more" which the parser can't understand. Remove the asterisk.
  • The "Didn't find the correct information for Pinckney Benton Stewart Pinchback" error is due to missing the SPACE within the last and first names. Add a \s in both the last_name and first_name character sets.
  • Remove extraneous \s after the trailing $.

It should then pass the challenge. Good Luck!!!

Thanks for your reply!

The *+ was actually a typo. Should have just been +.

Now I did as you reccomended and the test passed. But I don't quiet understand why we needed a space in the first and last name character sets as I don't see any names (first or last) including a space in them.

I you may just clarify that, I'd understand this 100%. Thank you in advance :)

Chris Freeman
Chris Freeman
Treehouse Moderator 68,166 Points

The space is need to capture the last name "Stewart Pinchback" and for the first name "Pinckney Benton"