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 trialHussein Almutawa
12,313 PointsCan'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'''
^(?P<last_name>[\w]+),\s
(?P<first_name>[\w]+):\s
(?P<score>[\d]+*)$\s
'''
, string, re.X|re.M)
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsYou'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!!!
Hussein Almutawa
12,313 PointsHussein Almutawa
12,313 PointsThanks 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
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsThe space is need to capture the last name "Stewart Pinchback" and for the first name "Pinckney Benton"