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 trialmark babyby
Full Stack JavaScript Techdegree Student 367 PointsI get this Python unsubscriptable error how do i solve it
def combiner(list_of_datas): sum = 0 words = [] for item in list_of_datas: if isinstance(item, str): words.append[item] else: sum += item return str(sum) + ''.join(words)
combiner(["apple", 5.2, "dog", 8])
def cobiner(list_of_datas):
sum=0
words = []
for item in list_of_datas:
if isinstance(item,str):
words.append[item]
else:
sum += item
return str(sum) + ''.join(words)
1 Answer
Steven Parker
231,248 PointsThere are a few issues here:
- the method here is named "cobiner" but the instructions ask for "combiner" (with an "m")
- the argument for the "append" method is in brackets but it should be parentheses
- the stringified numbers should be concatenated to the end of the words instead of the beginning
The second issue was the cause of the "not subscriptable" error.