dictionary keys automaticallyd {' ' ' ' ' ' for key in sorted( )print(key'=>' [key] = = = besides showcasing dictionariesthis use case serves to introduce the python for loop the for loop is simple and efficient way to step through all the items in sequence and run block of code for each item in turn user-defined loop variable (keyhereis used to reference the current item each time through the net effect in our example is to print the unordered dictionary' keys and valuesin sorted-key order the for loopand its more general colleague the while loopare the main ways we code repetitive tasks as statements in our scripts reallythoughthe for looplike its relative the list comprehension introduced earlieris sequence operation it works on any object that is sequence andlike the list comprehensioneven on some things that are not herefor exampleit is stepping across the characters in stringprinting the uppercase version of each as it goesfor in 'spam'print( upper() python' while loop is more general sort of looping toolit' not limited to stepping across sequencesbut generally requires more code to do sox while print('spam!xx - spam!spam!spam!spamspam!spam!spamspam!spamspamwe'll discuss looping statementssyntaxand tools in depth later in the book firstthoughi need to confess that this section has not been as forthcoming as it might have been reallythe for loopand all its cohorts that step through objects from left to rightare not just sequence operationsthey are iterable operations--as the next section describes dictionaries