[Tutor] traverse a two dimensional array

Emil kuffert_med_hat at hotmail.com
Thu Jun 19 01:03:04 CEST 2008



________________________________
> Date: Wed, 18 Jun 2008 19:43:21 +0530
> From: amit.pureenergy at gmail.com
> To: tutor at python.org
> Subject: [Tutor] (no subject)
>
> Hi , Could you please tell me , how i can traverse a two dimensional array , i am sorry , it must be pretty simple but I am new to python am not able to understand.
>
> --
> A-M-I-T S|S


Are you talking about an object which contains corresponding key value pairs? If so, in python it is called a dictionary and  look like this
 d = { 1 : 'a' , 2 : 'b' , 3 : 'c'}.   

I am not totally sure what you mean  by traverse. But if you are talking about how you access the values stored at a key, you simply do it by calling the key and then it returns the value like this:

       >>> d = { 1 : 'a', 2 : 'b', 3 : 'c'}         
       >>> d[1]
        'a'
       >>>


- Emil
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx


More information about the Tutor mailing list