Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assign a list to variables [duplicate]

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.

like image 678
khan Avatar asked Nov 23 '25 16:11

khan


1 Answers

You're doing it wrong.

G.label(*x)
like image 58
Ignacio Vazquez-Abrams Avatar answered Nov 25 '25 07:11

Ignacio Vazquez-Abrams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!