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

Ricardo Franco
seal-mask
.a{fill-rule:evenodd;}techdegree
Ricardo Franco
Data Analysis Techdegree Student 16,258 Points

Stuck on instances coding challenge

Hello, I created a dummy file in workspaces to test out the results in the Python shell. When I "print" out line 15 in the shell, I get the expected result. I simply changed the command to "return" as per the instructions and I am getting a "Didn't get the expected output" result. I know I am very close and am looking for a nudge. Thank you, in advance, for your assistance.

instances.py
def combiner(list):
    list = ["apple", 5.2, "dog", 8]
    strings = []
    numbers = []

    for item in list:
        if isinstance(item, str):
            strings.append(item)
        else:
            numbers.append(item)

    strings2 = ''.join(strings)
    numbers2 = str(float(sum(numbers)))

    return ''.join([strings2, numbers2])

combiner(list)

2 Answers

Steven Parker
Steven Parker
229,744 Points

Use the argument that is passed in, don't replace it with a literal. The data the challenge will be testing with will certainly not be the same as what was shown in the example.

And you should only define the function, you won't need to call it yourself.

Ricardo Franco
seal-mask
.a{fill-rule:evenodd;}techdegree
Ricardo Franco
Data Analysis Techdegree Student 16,258 Points

I'm not quite sure I understand when you say "Use the argument that is passed in". Per your hint, I removed the call to the function. I will keep troubleshooting in the mean time.

Ricardo Franco
seal-mask
.a{fill-rule:evenodd;}techdegree
Ricardo Franco
Data Analysis Techdegree Student 16,258 Points

I get it what you mean by not passing in an argument literal. Give it its own name to isolate it and provide it its own identity. Thanks.

Steven Parker
Steven Parker
229,744 Points

I just meant the 2nd line shouldn't be there.