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 trialKlemens Meyer
5,656 PointsI have no idea what is wrong. Code works fine in workspaces. Can anybody help me , please ?
def find_words(count, data): list1=[] list2 =[] count = int(count) list1 = re.findall(r'\w+', data) for item in list1 : if len(item) >= count : list2.append(item) list2.insert(0,count) print(list2)
import re
# EXAMPLE:
# >>> find_words(4, "dog, cat, baby, balloon, me")
# ['baby', 'balloon']
def find_words(count, data):
list1=[]
list2 =[]
count = int(count)
list1 = re.findall(r'\w+', data)
for item in list1 :
if len(item) >= count :
list2.append(item)
list2.insert(0,count)
print(list2)
3 Answers
Megan Amendola
Treehouse TeacherHi! The challenge is asking you to return the list not print it. Also, it only wants the words, but you've inserted the count at the beginning of the list which is also causing an issue.
def find_words(count, data):
list1=[]
list2 =[]
count = int(count)
list1 = re.findall(r'\w+', data)
for item in list1 :
if len(item) >= count :
list2.append(item)
# list2.insert(0,count)
# print(list2)
return list2
Klemens Meyer
5,656 PointsExample shows count at the beginning of the list that's why I inserted it there . Thank you very much for help . :)
Megan Amendola
Treehouse TeacherAh, I see! Let me break that down for you:
# EXAMPLE:
# This part of the example is showing the function call to show you an example
# of the info your function will be receiving
# >>> find_words(4, "dog, cat, baby, balloon, me")
# This is the output from the function, or what your function should return
# ['baby', 'balloon']
Klemens Meyer
5,656 PointsAll right, i got it now . Thanks for explanation . :)
Klemens Meyer
5,656 PointsKlemens Meyer
5,656 Pointsshould be string in place of data, but this don't fix problem.