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 trialMarkus von der Lühe
2,036 PointsDidn't get enough grous
I don't understand the problem. When running in colab it seems to work. I do have 2 groups it tells me not enough groups
import re
string = 'Perotto, Pier Giorgio'
pattern = r'[\w]+,\s[\w\s]+'
names = re.match(pattern, string)
1 Answer
Steven Parker
231,186 PointsI think you may be confusing character class with group. The code above has an appropriate pattern which contains two character classes, but it has no groups.
Groups identify portions of a match and are defined in a regex with parentheses.