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
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
On Sep 1, 1:21 pm, Alexandru Palade
[EMAIL PROTECTED] wrote:
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
lee a écrit :
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
On Sep 1, 1:45 pm, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
lee a écrit :
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',
On Sep 1, 1:45 pm, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
lee a écrit :
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',
On Sep 1, 1:45 pm, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
lee a écrit :
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',
On Sep 1, 1:45 pm, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
lee a écrit :
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',
lee a écrit :
hi, thank u your solution is exactly wat i wanted :)
I'm afraid it's not what you actually *need*, cf my other post.
--
http://mail.python.org/mailman/listinfo/python-list
lee wrote:
On Sep 1, 1:45 pm, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
lee a écrit :
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',
On Sep 1, 2:37 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:
lee wrote:
On Sep 1, 1:45 pm, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
lee a écrit :
hi,
i have a dictionary as follows :
kev : {'phno': ['dgsd', 'gsdg', 'dfsdf', 'g'], 'email': ['dg',
'sgsd', 'sdfsdf',
On Mon, 1 Sep 2008 03:51:13 -0700 (PDT), lee wrote:
i am soory for that keystrokes. can anyone tell me how can i change
the value of key.
suppose i have a dictionary
kev = {'kabir': ['[EMAIL PROTECTED]', '1234', 'missuri'], 'shri':
['[EMAIL PROTECTED]', '23423', 'india'], 'marsa': ['[EMAIL
On Sep 1, 3:59 pm, Wojtek Walczak [EMAIL PROTECTED] wrote:
On Mon, 1 Sep 2008 03:51:13 -0700 (PDT), lee wrote:
i am soory for that keystrokes. can anyone tell me how can i change
the value of key.
suppose i have a dictionary
kev = {'kabir': ['[EMAIL PROTECTED]', '1234', 'missuri'],
lee a écrit :
On Sep 1, 2:37 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:
lee wrote:
(snip)
i agree with u, my data strusture is not efficient. but all the
records,viz...name,phno, email,address are all generated at runtime ,
when the user enters them. so how can i design my datastructure
Alexandru Palade wrote:
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
slight variation:
lookfor = 'dfsdf'
for item, value in
15 matches
Mail list logo