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 trial

Python

Challenge instances.py could not be accepted

I've written this code. It works under PyCharm. I cannot figure out where is the mistake.

def combiner(*args): argstr = '' argnum = 0.0 for item in args: if isinstance(item, str): argstr = argstr + item else: argnum = argnum + float(str(item)) print(argstr + str(argnum)) return (argstr + str(argnum))

combiner("apple", 5.2, "dog", 8)

instances.py
def combiner(*args):
    argstr = ''
    argnum = 0.0
    for item in args:
        if isinstance(item, str):
            argstr = argstr + item
        else:
            argnum = argnum + float(str(item))
    return (argstr + str(argnum))

2 Answers

Steven Parker
Steven Parker
231,261 Points

The instructions say that the function "takes a single argument, which will be a list..."

So since there will only be one argument, you won't need a "splat" operator to gather several individual ones.

Otherwise, good job. :+1:

Wow, thank you so such for your prompt reply. I've spent several days on this simple challenge. With your help, now it works!! Thank you!!!

Steven Parker
Steven Parker
231,261 Points

Good news, but I didn't really do anything!