2

I have a python list:

x = ['aa', 'bb', 'cc']

The len() (or list length, which is 3 in this case) of this list can be any number, as it is basically coming from database. My question is: how can I assign each string member of this list into a separate variable automatically? The point over here is: I do not know the number of elements in the list, since they are always different.

Once this is resolved, I am trying to put it into a Python Google Charting (GChartWrapper's pie3d chart) function like this:

G.label(aa,bb,cc)

However, if I simply put the list in like:

G.label(x)

then it is naming only one section of the pie chart as the complete list.

khan
  • 7,005
  • 15
  • 48
  • 70
  • 4
    Thinking "Hey, it'd be nice if all these array items were named variables..." is almost always a bad idea. **That's what arrays (or lists) are for.** – voithos Aug 18 '12 at 06:02

1 Answers1

11

You're doing it wrong.

G.label(*x)
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358