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!
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
Arguments for MatchObject.groupdict() and MatchObject.group()
When you use MatchObject.groupdict() are you allowed to pass any arguments into it, for example if you want to get the contents of a specific group can you say MatchObject.groupdict("group name") or are you supposed to use MatchObject.group()? The reason I'm asking this is because of the question on the final quiz: "How would I get the contents of the group named email from my match object?" This was the code they gave me to fill in the blank "match_object.(put answer here)"
Chris FreemanTreehouse Moderator 68,404 Points
Referring to the MatchObjects docs, you can:
# refer to group number; first match match_obj.group(0) # refer to group name; named match match_obj.group(‘email’) # refer to tuple of matches; first match match_obj.groups() # refer to dict of named matches match_obj.groupdict()[‘group_name’]
Post back if you need more help. Good luck!!!