[Tutor] I am reading the tutorial alright?

Marc Tompkins marc.tompkins at gmail.com
Mon Mar 24 00:22:07 CET 2008


On Sun, Mar 23, 2008 at 4:16 PM, elis aeris <hunter92383 at gmail.com> wrote:

> in c++ i use array[n][n] to store things.
>
> how do i create an array like that?
>

Python doesn't have "arrays".  It has tuples, lists, and dictionaries.  A
quick Google will tell you the distinctions between them.

It looks to me like you want to create a list of lists....


t =[ ["item1", "item2", "item3"], ["itemA", "itemB", "itemC"], ["itemI",
"itemII", "itemIII"] ]

t[0][0] == "item1"
t[1][1] == "itemB"
t[2][2] == "itemIII"





>
>
>
>
>
> On Sun, Mar 23, 2008 at 4:13 PM, bob gailer <bgailer at alum.rpi.edu> wrote:
>
> > elis aeris wrote:
> > > t = 12345, 54321, "hello!"
> > > print t[0]
> > >
> > > the way the 3 items are saved and access fits my need, now how do I
> > > make t have more than one entry so effectively I get this?
> > >
> > > t[n][n]
> > >
> > (1) are you going through the tutorials as requested?
> > (2) please learn how to ask meaningful questions
> > For example t[n][n] does not communicate the outcome you desire.
> > In Python t[n][n] would get you the nth element of the nth element of t.
> > For example if n were 2 you'd get 3. If that is what you want you just
> > answered your own question, as a simple test in the Python interactive
> > window would reveal.
> >
> > Otherwise we can only guess as to what you want and that wastes all of
> > our time!
> >
> > It would be far more effective to show us what the result would look
> > like based on the data you entered into t.
> >
> > PLEASE do as much as you can to solve problems yourself and express
> > questions CLEARLY!
> >
> > --
> > Bob Gailer
> > 919-636-4239 Chapel Hill, NC
> >
> >
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
www.fsrtechnologies.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080323/21573f21/attachment.htm 


More information about the Tutor mailing list