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 trialRobert Raiz
2,811 PointsNeed player.py final task tweak
Hello, I get the Bummer error but the rest of the message looks ok to me: Got "{'last_name': 'Pinckney Benton', 'score': '18', 'first_name': 'Stewart Pinchback'}"
Can you please point me to where it refused my code?
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<first_name>[\w]+\s[\w]+?),\s(?P<last_name>[\w]+\s[\w]+):\s(?P<score>\d{2})', string, re.M)
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsYour code is very close. The space in the first_name
and last_name
expressions needs to be optional. Add a "?
" after each space. "\s
" becomes "\s?
":
players = re.search(r'(?P<first_name>[\w]+\s?[\w]+?),\s(?P<last_name>[\w]+\s?[\w]+):\s(?P<score>\d{2})', string, re.M)
Robert Raiz
2,811 PointsThank you!