[Tutor] Help me with two dimensional arrays in Python

Luke Paireepinart rabidpoobear at gmail.com
Wed Oct 4 15:49:51 CEST 2006


Asrarahmed Kadri wrote:
>
> Hi folks,
>  
> I am stuck.. Please help me with implementing two dimensional array in 
> Python.
>  
There are no such things as arrays in Python, silly!
I can help you with a two-dimensional list, though :)


Okay, imagine that a list of integers (or any other objects) is a single 
object itself,
that keeps track of the integers (or other objects) for you in whatever 
order you want.
somelist = [1,2,3,4,5]
anotherlist = [6,7,8,9,10]

Now what you want out of a two-dimensional list is
where there are multiple inner lists, with each individual
list being a full row, right?
so...
two_dimensional = [somelist,anotherlist]

Or:
two_dimensional = [ [1,2,3,4,5] , [6,7,8,9,10] ]

This isn't a homework question, right?

Good luck,
-Luke


More information about the Tutor mailing list