By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,421 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,421 IT Pros & Developers. It's quick & easy.

Python Dict-List

P: 3
If you have a dict with a list how do you get the info from the list.
Jun 8 '12 #1
Share this Question
Share on Google+
4 Replies

P: 6
What do you mean get info list?
Jun 8 '12 #2

P: 3
Expand|Select|Wrap|Line Numbers
  1. 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
@WooDoo
Jun 8 '12 #3

P: 6
Expand|Select|Wrap|Line Numbers
  1. dict = {'Alice': ["2","bookclub",],'Jane': ["3","mat club"]}
  2. for x,y in enumerate(dict):
  3.     # x is the dict key
  4.     # y is the list
  5.     for item in dict[y]:#dict[y] is lookup the item with the dict key        
  6.         print(y,item)
Jun 8 '12 #4

P: 3
Thanks for your help...............
Jun 8 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.