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 trialVictor Gavojdea
11,796 PointsNot sure what to put as the search pattern, nothing I'm trying seems to be working.
I'm sure its obvious but I'm stumped. Looking at solutions on stackoverflow involving [a-zA-Z] is just confusing me more.
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsThe challenge asks "return a list of the words in the string that are 'count' word
characters long or longer". In a regular expression search a word character is represented with \w
. To find count
many characters, you can multiply this short string by count
. Then to also find words of greater length, you can search for \w*
which means "zero or more word characters". putting these together you get:
import re
βdef find_words(count, string):
return re.findall(r'\w' * count + '\w*', string)
Victor Gavojdea
11,796 PointsVictor Gavojdea
11,796 PointsThank you. :)
Ivan Bodnar
2,419 PointsIvan Bodnar
2,419 PointsThanks Chris, I was stuck too, I was trying to do it with .format()