Python Dict-List

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dane R
    New Member
    • Jun 2012
    • 3

    Python Dict-List

    If you have a dict with a list how do you get the info from the list.
  • WooDoo
    New Member
    • Jun 2012
    • 6

    #2
    What do you mean get info list?

    Comment

    • Dane R
      New Member
      • Jun 2012
      • 3

      #3
      sample of the dict

      Code:
      dict = {'Alice': ["2","bookclub",],'Jane': ["3","mat club"]}
      This is a sample of the dict, I need to print the person name and then the persons info next to their name
      Originally posted by WooDoo
      What do you mean get info list?

      Comment

      • WooDoo
        New Member
        • Jun 2012
        • 6

        #4
        Code:
        dict = {'Alice': ["2","bookclub",],'Jane': ["3","mat club"]}
        for x,y in enumerate(dict):
            # x is the dict key
            # y is the list
            for item in dict[y]:#dict[y] is lookup the item with the dict key        
                print(y,item)

        Comment

        • Dane R
          New Member
          • Jun 2012
          • 3

          #5
          Thanks for your help........... ....

          Comment

          Working...