learning python and have come up with a question about something I'm trying to do. Earlier in the program I've created a series of lists through looping and adding elements if they meet some condition after some calculations. As an example these are:
v0 = [2110, 2110]
v1 = [2270, 2297, 2206, 2075]
v2 = [2220, 2024, 2203, 2022]
v3 = [2052, 2101, 2150, 2053]
v4 = [2079, 2609, 2065, 2082]
Now that I've generated these, I want to make a list of lists that is later converted into a dataframe for the type of bar plot I want to create.
so I've tried this:
i = 0
for i in xrange(B): #where B is = 5
A1.append("v"+str(i))
which yields:
In[21]: A1
Out[21]: ['v0', 'v1', 'v2', 'v3', 'v4']
and what I really want is:
A1 = [v0,v1,v2,v3,v4]
A1
Out[26]: [[2110, 2110],[2276, 2277, 2276, 2275],[2220, 2024, 2203, 2022],[2052, 2101, 2150,2053], [2079, 2609, 2065, 2082]]
I need to be able to iterate over the lists since they can always be different in number and length. Any suggestions on how to access the list contents in the list of lists are very much appreciated!