of theseusing the dictionary' keys iterator is probably preferable in xand works in as welld {' ' ' ' ' ' for in sorted( )print(kd[ ] better yetsort the dict directly dict iterators return keys dictionary magnitude comparisons no longer work in secondlywhile in python dictionaries may be compared for relative magnitude directly with and so onin python this no longer works howeveryou can simulate it by comparing sorted keys lists manuallysorted( items()sorted( items()like dictionary equality tests ( = still work in xthough since we'll revisit this near the end of the next in the context of comparisons at largewe'll postpone further details here the has_key method is dead in xlong live infinallythe widely used dictionary has_key key presence test method is gone in insteaduse the in membership expressionor get with default test (of thesein is generally preferred) {' ' ' ' ' ' has_key(' ' onlytrue/false attributeerror'dictobject has no attribute 'has_key'cin true 'xin false if 'cin dprint('present' [' ']present print( get(' ') print( get(' ')none if get(' '!noneprint('present' [' ']present lists and dictionaries required in preferred in today branch on result fetch with default another option