[Tutor] selecting elements from dictionary

Hs Hs ilhs_hs at yahoo.com
Wed Sep 15 04:10:59 CEST 2010


dear group:

I have a dictionary object that looks like this:



xdic
{11135457: [1], 11135492: [1], 11135913: [1], 11135436: [1, 2], 11135699: [1, 
2], 11135702: [1, 3], 11135901: [1]}


I want to print only those items that have [1,2] and [1,3]  in any order, such 
as [1,2] or [2,1], [3,1] or [1,3]


>>> for item in xdic.keys():
...     if [1,2] in xdic[item]:
...             print item


I get a wrong answer, I know the values are there. How can I print only those 
item that have [1,2] and [1,3]

Thank you. 
h


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100914/f89e9410/attachment.html>


More information about the Tutor mailing list