[Tutor] Help me with two dimensional arrays in Python
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Wed Oct 4 23:20:34 CEST 2006
>>>> I am stuck.. Please help me with implementing two dimensional array
>>>> in Python.
Hi Asrarahmed,
What do you need a two-dimensional array for? This is a serious question:
what's your application? What are you trying to represent, and why?
As a glib possible answer: you can use a dictionary to map 2-tuples to
values. If you think about it, that's almost what a 2d array does in
other languages.
##################
points = {}
points[(3, 4)] = 1
points[(1, 7)] = 2
##################
But this may not be the right approach for your problem. Tell us more of
what you are trying to do.
More information about the Tutor
mailing list