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 trial

Python Regular Expressions in Python Introduction to Regular Expressions Players Dictionary and Class

Jose Mena
PLUS
Jose Mena
Courses Plus Student 18,978 Points

What is the output they want for Stewart Pinchbeck, Pinckney Benton: 18??

I made a regular expression that returns this

first_name Pinckney Benton last_name Stewart Pinchback score 18

And another one that returns this:

Match 5 first_name Pinchback last_name Stewart score None

Match 6 first_name Benton last_name Pinckney score 18

Which makes sense to me (Pinchbeck Stewart does not have a score), but since none of them work, I do not think it is clear what the output is supposed to be, any help is appreciated

players.py
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]+)[,\s]+(?P<first_name>[\w\s]+)[,:\s]*(?P<score>\d+)', string, re.M)

2 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

You didn't find a bug but you did find a place where I needed a more accurate error message. Try it again now and see if you find what was off; it's a pretty small oversight.

Steven Parker
Steven Parker
231,269 Points

You may have discovered a bug.

Your expression above looks good to me. I tried substituting an actual space (" ") for the first whitespace character class ("\s") and it then passed the challenge, so you might try that yourself just to move on.

But you may also want to submit this as a bug on the Support page.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Hmm, that's strange that that passes it. I'm not sure why that makes a difference, actually.