How can i retrieve a key from a dictionary?

Terry Reedy tjreedy at
Mon Nov 5 05:41:26 CET 2001

"Husam" <h.jehadalwan at> wrote in message
news:3BE519E0.34312B48 at
> how can one retrieve or select a key from a dictionary?
> dict={}
> dict[1]='one'
> dict[2]='two'
> dict.keys() will gets all the keys. but, i need to select explicitly
> key for printing along its value.

If you just want some key,value pair,  and pair, check out dict.pop().
Otherwise, not clear what you are trying to do.

Terry J. Reedy

More information about the Python-list mailing list