Issue
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()
function.)Sample run:
print( concat(['a', 'bcd', 'e', 'fg']) ) abcdefg
Solution
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)