Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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,029 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!!!