> I am working on a project in which I generate an array of values > (list_array). I need to use the values in this array to create list > similar to the one below: > > list_array = [] > list = item1,item2,itemN... > > I am having difficulty in getting the values out of the original array. > I have tried enumerating over the array, but the results are not what > I need. When I attempt to simply print list, I get the following > output: > > print list > ['item1', 'item2', ..., 'itemN'] > > I can get list to be how I want it if I use the index value as follows: > > list = ("%s" + "," + "%s", ...) % (list_array[0], list_array[1], ... > > However, the list_array will never contain a constant number of items. > So my dilema is how to loop/iterate through list_array to create list > in the format I want. > > Any suggestions are greatly appreciated.
I'm not sure if I understand exactly what you want, but if all you need is turning a list into a tuple then just use the function tuple: >>> mylist = [ 1, 2, 3 ] >>> mytuple = tuple( mylist ) >>> print mylist [1, 2, 3] >>> print mytuple (1, 2, 3) >>> -- http://mail.python.org/mailman/listinfo/python-list