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 trialJames Mazurski
4,430 PointsTypeError: __init__() takes 1 positional argument but 2 were given
Im getting a TypeError and cannot figure out how to get past this quiz....any ideas?
with the input ["apple", 5.2, "dog", 8], combiner should return "appledog13.2"
class combiner(): def init(self): self.string = [] self.listing = [] self.total = 0
def function(self,info):
info2 = list(info)
for item in info2:
if isinstance(item,str) is True:
self.string.append(item)
elif isinstance(item,int) is True:
self.total += item
self.listing.append(item)
elif isinstance(item,float) is True:
self.total += item
self.listing.append(item)
return ''.join(self.string)+''+ str(self.total)
#with the input ["apple", 5.2, "dog", 8], combiner would return "appledog13.2"
class combiner():
def __init__(self):
self.string = []
self.listing = []
self.total = 0
def function(self):
info2 = list(self)
for item in info2:
if isinstance(item,str) is True:
self.string.append(item)
elif isinstance(item,int) is True:
self.total += item
self.listing.append(item)
elif isinstance(item,float) is True:
self.total += item
self.listing.append(item)
return ''.join(self.string)+''+ str(self.total)
1 Answer
Steven Parker
231,261 PointsYou're working way too hard!
The instructions are to "Create a function named combiner
...", but this code creates an entire class instead.