Python Object-Oriented Python Inheritance Instances

youssef b10ta
PRO
youssef b10ta
Pro Student 2,754 Points

Didn't get the expected output?? maybe you didnt expected the way i did slove it ....

def combiner(strings):
    string = ' '
    number = 0
    for i in strings:
        if isinstance(i,(int,float)):
            number += i
        else:
            string += i
    return f"{string}{number}"

1 Answer

KRIS NIKOLAISEN
KRIS NIKOLAISEN
53,693 Points

You initialized string with a space so there will be a leading space in your result.

Use:

string = ''

instead of:

string = ' '