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 trialAbhishek Gangadhar
9,467 PointsNot sure whats wrong with my code
Its say that an empty list is being returned. not sure why...
import re
# EXAMPLE:
# >>> find_words(4, "dog, cat, baby, balloon, me")
# ['baby', 'balloon']
def find_words(count,string):
match = re.findall(r"\w{count,}",string)
return match
1 Answer
Keith Whatling
17,759 PointsHi,
Your expression is 100% correct, however you will need to take the variable 'count' and put it in your code.
At the moment count is just a word in the string and not the variable you are passing. Try the following.
re.findall(r'\w{' + str(count) + '}', string)
I would love to know how to use the curly braces with string.format(count), if you find out then please ping me. Maybe we should ask Kenneth to shine some light on that one.
Josh Keenan
20,315 PointsJosh Keenan
20,315 PointsTagging Kenneth Love so maybe he can help you guys out :)
Abhishek Gangadhar
9,467 PointsAbhishek Gangadhar
9,467 Pointslol ya silly mistake :) re.findall(r'\w{' + str(count) + ',}', string)
we also need to use the ',' (comma) cause we need all strings with 6 or more letters
Iskander Ismagilov
13,298 PointsIskander Ismagilov
13,298 Points