index-based for loops the simplicity of standard for loop over the elements of list is wonderfulhoweverone limitation of that form is that we do not know where an element resides within the sequence in some applicationswe need knowledge of the index of an element within the sequence for examplesuppose that we want to know where the maximum element in list resides rather than directly looping over the elements of the list in that casewe prefer to loop over all possible indices of the list for this purposepython provides built-in class named range that generates integer sequences (we will discuss generators in section in simplest formthe syntax range(ngenerates the series of values from to convenientlythese are precisely the series of valid indices into sequence of length thereforea standard python idiom for looping through the series of indices of data sequence uses syntaxfor in range(len(data))in this caseidentifier is not an element of the data--it is an integer but the expression data[jcan be used to retrieve the respective element for examplewe can find the index of the maximum element of list as followsbig index for in range(len(data))if data[jdata[big index]big index break and continue statements python supports break statement that immediately terminate while or for loop when executed within its body more formallyif applied within nested control structuresit causes the termination of the most immediately enclosing loop as typical examplehere is code that determines whether target value occurs in data setfound false for item in dataif item =targetfound true break python also supports continue statement that causes the current iteration of loop body to stopbut with subsequent passes of the loop proceeding as expected we recommend that the break and continue statements be used sparingly yetthere are situations in which these commands can be effectively used to avoid introducing overly complex logical conditions