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

Chaya Feigelstock
Chaya Feigelstock
2,429 Points

My code works in my REPL and does what it's supposed to, but in the exercise says "didn't get expected output."?

def combiner(new_list): string_list = [] integer_list = [] for new in new_list: if isinstance(new, str): string_list.append(new) elif isinstance(new, int): integer_list.append(new)

int_list_sum = sum(integer_list) int_sum_string = str(int_list_sum) combine_string_list = "".join(string_list) combination = combine_string_list+int_sum_string

return combination

instances.py
def combiner(new_list):
    string_list = []
    integer_list = []
    for new in new_list:
        if isinstance(new, str):
            string_list.append(new)
        elif isinstance(new, int):
            integer_list.append(new)

    int_list_sum = sum(integer_list)
    int_sum_string = str(int_list_sum)
    combine_string_list = "".join(string_list)
    combination = combine_string_list+int_sum_string

    return combination

1 Answer

If you use the sample data given ["apple", 5.2, "dog", 8] you get appledog8 instead of appledog13.2. What about floats?

Chaya Feigelstock
Chaya Feigelstock
2,429 Points

Thanks so much!! This was very helpful - I missed that detail :)