[SOLVED] Write a function that accepts a list of strings and concatenates them


Write a function called concat() that takes a list of strings as an
argument and returns a single string that is all the items in the list
concatenated (put side by side). (Note that you may not use the join()

Sample run:

print( concat(['a', 'bcd', 'e', 'fg']) )


In Python, you can just use the + operator to concatenate two strings. In your case, you can do something like this:

def concat(list_args):
    res = ""
    for w in list_args:
        res += w
    return res

Then if you run

print(concat(['a', 'bcd', 'e', 'fg']))

you get abcdefg

Answered By – sandbar

Answer Checked By – Senaida (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *