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

Python Regular Expressions in Python Introduction to Regular Expressions Compiling and Loops

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)"

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 68,404 Points

Referring to the MatchObjects docs, you can:

# refer to group number; first match

# refer to group name; named match

# refer to tuple of matches; first match

# refer to dict of named matches

Post back if you need more help. Good luck!!!