473,698 Members | 2,643 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python Dict-List

3 New Member
If you have a dict with a list how do you get the info from the list.
Jun 8 '12 #1
4 2181
WooDoo
6 New Member
What do you mean get info list?
Jun 8 '12 #2
Dane R
3 New Member
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
WooDoo
6 New Member
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
Dane R
3 New Member
Thanks for your help........... ....
Jun 8 '12 #5

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

Similar topics

12
2842
by: Don Bruder | last post by:
A week or two ago, I asked here about porting Python to C. Got some good answers (Note 1) but now I've got another question. Actually, more a request for clarification of a topic that both the Python tutorial and docs leave a touch murky to my understanding. Dictionaries/"dict" types... Am I understanding/interpreting correctly when I go with the idea that a "dict" variable can be looked at as (effectively) two parallel arrays?...
1
1407
by: venu gopal | last post by:
Hello people, iam finding great difficulty in handling a two-dimentional dictionary or any other similar data structure for the following purpose: from a collection of words,i need to have the count of each word so if i use: str=f.getline() for l in range(flen): if subs.has_key(str): subs=1 else:
9
14283
by: Neil Benn | last post by:
Hello, I can't find the docs for __eq__ on a dict and I can't find a description on what the eq does (strangely it does implement > and < but I have no idea what that does). Does anyone know (definitively) what the __eq__, __gt__, __lt__ methods do. BTW, google is not my friend - I invited it out for a drink last week and it stood me up :-).
16
4074
by: chosechu | last post by:
Hello Pythoneers: I need to pass a list of named arguments to a function in a given order, and make sure these named arguments are retrieved using keys() in the same order they were given. Example: keyargs={} keyargs=1 keyargs=2
10
1874
by: could.net | last post by:
Python dict is a hash table, isn't it? I know that hashtable has the concept of "bucket size" and "min bucket count" stuff, and they should be configurable so I can set them to the proper value when I know how many items I'm going to handle. If these two values can't be set, the hashtable will give them default values. When there are more and more items being added to the hashtable, it increase its buckets and copy the old items into...
3
1578
by: james_027 | last post by:
Hi, class UserDict: def __init__(self, dict=None): self.data = {} if dict is not None: self.update(dict) I just don't understant this code, as it is not also mention in the book. the update is a method of a dict right? in my understanding the last statement should be self.data.update(dict).
3
2184
by: dmitrey | last post by:
hi all, what's the best way to write Python dictionary to a file? (and then read) There could be unicode field names and values encountered. Thank you in advance, D.
3
1658
by: kj | last post by:
Hi. Does anyone know of a module that will take a suitable Python dictionary and return the corresponding XML structure? In Perl I use XML::Simple's handy XMLout function: use XML::Simple 'XMLout'; my %h = ( 'Foo' =+{ 'Bar' =+{ 'Baz' =, 'eenie' =4,
15
1752
by: andyhume | last post by:
Hello... I have a dict of key/values and I want to change the keys in it, based on another mapping dictionary. An example follows: MAPPING_DICT = { 'a': 'A', 'b': 'B', }
0
1220
by: danielo | last post by:
i have a python function like this : def func1(**fields) : ... fields is a python dict, in python i can send the following to the function : c = dict(a="3",b="4",f="3") func1(**c)
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.