Re: Joining elements in a list to 1 element

2007-08-23 Thread Francesco Guerrieri
On 8/23/07, J. Cliff Dyer <[EMAIL PROTECTED]> wrote: > > What do you want to have happen in this case? > > my_list = [ 'a', 4, 'c' ] > It depends on the requirements of the OP. A possible solution could be: my_second_list = [] try: my_second_list.append("".join(my_list)) except TypeError:

Re: Joining elements in a list to 1 element

2007-08-23 Thread Francesco Guerrieri
On 8/23/07, dimitri pater <[EMAIL PROTECTED]> 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_seco

Joining elements in a list to 1 element

2007-08-23 Thread dimitri pater
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 I have tried the following: myList = ['a','b','c'] print myList >>>['a', 'b', 'c'] # get type print type(myList) >>> # get length print len(myList) >>>3 myList2 = '