#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    133
    Rep Power
    11

    Python dictionaries and lists


    Say i have a list in a dictionary, like this:
    Code:
    dictionary_name = {'key1':['list1_value','list1_value2'], 'key2':['list2_vakue','list2_value2']}
    And so on. Now how would I grab one of those lists so I can loop through them?

    If my explenation was not clear enough, please say so.
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    155
    Code:
    dictionary_name = {'key1':['list1_value','list1_value2'], 'key2':['list2_vakue','list2_value2']}
    dictionary_name['key1'][0] would be 'list1_value'.
    dictionary_name['key1'][1] would be 'list1_value2'.

    The value of dictionary_name['key1'] would be a list.
    Understand?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    133
    Rep Power
    11
    Originally Posted by †Yegg†
    Code:
    dictionary_name = {'key1':['list1_value','list1_value2'], 'key2':['list2_vakue','list2_value2']}
    dictionary_name['key1'][0] would be 'list1_value'.
    dictionary_name['key1'][1] would be 'list1_value2'.

    The value of dictionary_name['key1'] would be a list.
    Understand?
    I do, thank you

IMN logo majestic logo threadwatch logo seochat tools logo