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 trialTopher Knoll
3,572 PointsBummer: Hmm, no .groups() attribute. Did you do a match?
I'm not quite sure what this even means [as usual.] This vague bummer code doesn't make sense. The lesson teaches us to use .groupsdict() which is the root of the problem I guess. I don't remember there being anything about .groups(). Anyway, I use both on the names string and it gives me either this error or something about there not being a .groupsdict() method.
Stuck yet again.
import re
string = 'Perotto, Pier Giorgio'
names = re.match(r'''
^(?P<first>[\w ]+),\s
(?P<last>[\w ]+)
''', string, re.X|re.M)
names = names.groupdict()
2 Answers
Steven Parker
231,268 PointsThe instructions only ask for the result of the "re.match" to be assigned to "name". The extra step is replacing what would otherwise be a correct result with one of it's attributes.
Topher Knoll
3,572 PointsOkay. I just removed the last line. Confusing directions... But, thanks!