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

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,331 Points

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 :)