Advertisement
vojd

python array key

Feb 20th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. # first lets create an associative array (or dictionary as its called in python)
  2. a = {10 : 'cat', 20 : 'bird'}
  3.  
  4. # the dictionary 'a' has a method called keys() which returns all its keys
  5. # and since we're interested in the first (with index 0) we'll get it through:
  6.  
  7. print a.keys()[0]
  8.  
  9. # result: 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement