lookfor = 'dfsdf'
for item, value in kev.items():
       if lookfor in value:
               print item
               print value.index(lookfor)
               break   # assuming you only want one result


You can also skip the 'if' verification in which case you need to catch
ValueError exception in case there is no such entry in the current list.

Hope it helps.

lee wrote:
hi,
i have a dictionary as follows :
kev :  {'phno': ['dgsd', 'gsdg', 'dfsdf', 'g'], 'email': ['dg',
'sgsd', 'sdfsdf', 'gdf'], 'name': ['ds', 'dsg', 'dsfds', 'fgdf'],
'address': ['sdg', 'dsgsdg', 'sdf', 'dfg']}

if user is enters the 3rd item of key phno, ie "dfsdf" in my dict,
how can i find it is the third  item in the internal list of phno of
that dictionary?  thanks you.
--
http://mail.python.org/mailman/listinfo/python-list


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to