Hi,
I want to have many lists, such as list0, list1, list2, ..., each one
holding different number of items.
Is there something like
list[0]
list[1]
list[2]
so that I can iterate through this list of lists?
Thanks!
bahoo 3 1446
On Apr 3, 7:12 pm, "bahoo" <b83503...@yahoo.comwrote:
Hi,
I want to have many lists, such as list0, list1, list2, ..., each one
holding different number of items.
Is there something like
list[0]
list[1]
list[2]
so that I can iterate through this list of lists?
Thanks!
bahoo
listOfLists = [[1,2], [5,7,9], [4,2,1,4,6,6]]
No problem there. The lists can contain any objects, including lists.
for x in listOfLists:
print 'list:',
for y in x:
print y,
print
On Apr 3, 10:12 am, "bahoo" <b83503...@yahoo.comwrote:
Hi,
I want to have many lists, such as list0, list1, list2, ..., each one
holding different number of items.
Is there something like
list[0]
list[1]
list[2]
so that I can iterate through this list of lists?
Thanks!
bahoo
list0 = [1]
list1 = [2,3,4,5]
list2 = [6,7,8]
allLists =[list0, list1, list2]
print allLists[1][3]
print allLists[0][0]
bahoo a écrit :
Hi,
I want to have many lists, such as list0, list1, list2, ..., each one
holding different number of items.
Is there something like
list[0]
list[1]
list[2]
so that I can iterate through this list of lists?
listoflists = [
[1, 2, 3],
["foo", "bar", "baaz", "quux"],
["A", "B", "C", "D", "E"]
]
for alist in listoflists:
for item in alist:
print item This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: derek / nul |
last post by:
Is there any list or array code that can load lines from a file?
ie what I would like is to open a file and load line by line into a list or
array.
Any pointers most appreciated.
Derek
|
by: Fuzzyman |
last post by:
Pythons internal 'pointers' system is certainly causing me a few
headaches..... When I want to copy the contents of a variable I find
it impossible to know whether I've copied the contents *or*...
|
by: Bart Nessux |
last post by:
I understand how a Python list can be broken into smaller lists by using
slice like this:
new_small_list_1 = BIG_LIST #0-1000
new_small_list_2 = BIG_LIST #1001-2000
new_small_list_3 =...
|
by: Chris Ritchey |
last post by:
Hmmm I might scare people away from this one just by the title, or
draw people in with a chalange :)
I'm writting this program in c++, however I'm using char* instead of
the string class, I am...
|
by: Jon Slaughter |
last post by:
I'm using C++ and I'm trying to create a list of a list and it won't let me
create an iterator for it. if I do a list of an int, everything is fine.
my syntax is
list<list<string> > some_list;...
|
by: MLH |
last post by:
Gentlemen: I have declared an array
Dim MyTables(14) AS Long
Now I want to assign values for MyTables(0) - MyTables(14) equal
to the number of records in each table. Catch, I want the code...
|
by: Dan Nordquist |
last post by:
Hey everyone.
I'm just getting my feet wet with ADSI (and VB.NET, and ASP.NET,
really), but I'm wondering if there's a way to pull a list of
distribution lists from an Exchange server using...
|
by: unwantedspam |
last post by:
Hello All,
Thank you in advance. I have a quick question about array lists. Why
does the following code give me the same results if I reference two
different elements?
Dim myList As New...
|
by: hareen |
last post by:
hi can any one tell how to handle .NET Dll Methods Which have return types Generic Lists and DataTables
|
by: Adam Sandler |
last post by:
Hello,
I have 2 questions about using array lists.
1. I have a method which returns an arraylist. I'd like to put the
contents of what is returned into another arraylist:
ArrayList al =...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |