Is it possible to specify the size of list at construction?
Anthony Liu
antonyliu2002 at yahoo.com
Tue Mar 1 15:50:40 EST 2005
Yes, that's helpful. Thanks a lot.
But what if I wanna construct an array of arrays like
we do in C++ or Java:
myArray [][]
Basically, I want to do the following in Python:
myArray[0][1] = list1
myArray[1][2] = list2
myArray[2][3] = list3
How to do this, gurus?
--- Michael Spencer <mahs at telcopartners.com> wrote:
> Anthony Liu wrote:
> > I cannot figure out how to specify a list of a
> > particular size.
> >
> > For example, I want to construct a list of size
> 10,
> > how do I do this?
> >
> A list does not have a fixed size (as you probably
> know)
>
> But you can initialize it with 10 somethings
> >
> >>> [None]*10
> [None, None, None, None, None, None, None, None,
> None, None]
> >>> range(10)
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
> >>>
>
> Michael
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Python-list
mailing list