Lets say I have a list:
a = ['a','b','c']
which is list of string.
Now I want to iterate in such way that I get abc
. How can I do that ?
"".join(a)
should do it for you.
or
"".join(map(str, a))
if all elements are not strings
Another slightly less pythonic way:
string = ''
for letter in a:
string += letter
Another alternative to one mentioned by vks. This assumes that the list contains elements which are str or support the + operator in a way that it aligns with the semantics of appending.
functools.reduce(lambda x,y: x+y, ['a','b','c'])