I'm trying to traverse a dictionary looking for partial matches of the
key, and I'm not sure how.  Here's a sample dictionary:

dict = {00001234 : value1, 20051234 : value2, 20071234 : value3}

Here's what I'm trying to do:

for key in dict:
    if key == 0000???? or key == 2005????:
        do something with dict[key]

The challenge is that I only care about the first four digits of the key
for the purpose of this match - is there a way to express this?  I could
probably create a wrapper dictionary using just the first four digits of
the key as they key, and containing the original key:value pair as a
list within it, but that seems cumbersome.  Any one have a suggestion?
Thanks.
-- 

yours,

William

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to