Joining elements in a list to 1 element

Francesco Guerrieri f.guerrieri at gmail.com
Thu Aug 23 06:43:54 EDT 2007


On 8/23/07, dimitri pater <dimitri.pater at gmail.com> wrote:
>
> Dear all,
> I am having trouble joining elements in a list into 1 element.
> e.g. ['a','b','c'] into ['abc'] so that len(list) returns 1
>
>
You need to append the joined string to your new list.
For instance
my_list = ["a", "b", "c"]
my_second_list = []
my_second_list.append("".join(my_list))

bye,
Francesco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070823/9855b082/attachment.html>


More information about the Python-list mailing list