manual iterationwhat for loops usually do while truetrytry statement catches exceptions next(ior call __next__ in except stopiterationbreak print( * end=' to understand this codeyou need to know that try statements run an action and catch exceptions that occur while the action runs (we met exceptions briefly in but will explore them in depth in part viii should also note that for loops and other iteration contexts can sometimes work differently for user-defined classesrepeatedly indexing an object instead of running the iteration protocolbut prefer the iteration protocol if it' used we'll defer that story until we study class operator overloading in other built-in type iterables besides files and physical sequences like listsother types have useful iterators as well the classic way to step through the keys of dictionaryfor exampleis to request its keys list explicitlyd {' ': ' ': ' ': for key in keys()print(keyd[key] in recent versions of pythonthoughdictionaries are iterables with an iterator that automatically returns one key at time in an iteration contexti iter(dnext( 'anext( 'bnext( 'cnext(itraceback (most recent call last)file ""line in stopiteration the net effect is that we no longer need to call the keys method to step through dictionary keys--the for loop will use the iteration protocol to grab one key each time through iterations and comprehensions