I would like to print a specific Python dictionary key:
mydic = {} mydic[\'key_name\'] = \'value_name\'
Now I can check if mydic.has_
mydic.has_
Try this:
def name_the_key(dict, key): return key, dict[key] mydict = {'key1':1, 'key2':2, 'key3':3} key_name, value = name_the_key(mydict, 'key2') print 'KEY NAME: %s' % key_name print 'KEY VALUE: %s' % value