iteration and looping the most widely used looping construct is the for statementwhich is used to iterate over collection of items iteration is one of python' richest features howeverthe most common form of iteration is to simply loop over all the members of sequence such as stringlistor tuple here' an examplefor in [ , , , , , , , , ]print " to the % power is % ( **nin this examplethe variable will be assigned successive items from the list [ , , , , on each iteration because looping over ranges of integers is quite commonthe following shortcut is often used for that purposefor in range( , )print " to the % power is % ( **nthe range( , [,stride]function creates an object that represents range of integers with values to - if the starting value is omittedit' taken to be zero an optional stride can also be given as third argument here' an examplea range( range( , range( , , range( , ,- , , , , , , , , , , , , , , , , , , , , one caution with range(is that in python the value it creates is fully populated list with all of the integer values for extremely large rangesthis can inadvertently consume all available memory thereforein older python codeyou will see programmers using an alternative function xrange(for examplefor in xrange( )statements , , , the object created by xrange(computes the values it represents on demand when lookups are requested for this reasonit is the preferred way to represent extremely large ranges of integer values in python the xrange(function has been renamed to range(and the functionality of the old range(function has been removed the for statement is not limited to sequences of integers and can be used to iterate over many kinds of objects including stringslistsdictionariesand files here' an examplea "hello worldprint out the individual characters in for in aprint ["dave","mark","ann","phil"print out the members of list for name in bprint name 'goog 'ibm 'aapl print out all of the members of dictionary for key in cprint keyc[keyprint all of the lines in file open("foo txt" lib fl ff