items in an array

shkelley at gmail.com shkelley at gmail.com
Wed Apr 19 10:04:01 EDT 2006


Hi All -

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.

-Shawn




More information about the Python-list mailing list