control structures and functions method does the same thingbut on failureinstead of raising an exception it returns an index of - there is no equivalent method for listsbut if we wanted function that did thiswe could create one using while loopdef list_find(lsttarget)index while index len(lst)if lst[index=targetbreak index + elseindex - return index this function searches the given list looking for the target if the target is foundthe break statement terminates the loopcausing the appropriate index position to be returned if the target is not foundthe loop runs to completion and terminates normally after normal terminationthe else suite is executedand the index position is set to - and returned for loops like while loopthe full syntax of the for in loop also includes an optional else clausefor expression in iterablefor_suite elseelse_suite the expression is normally either single variable or sequence of variablesusually in the form of tuple if tuple or list is used for the expressioneach item is unpacked into the expression' items if continue statement is executed inside the for in loop' suitecontrol is immediately passed to the top of the loop and the next iteration begins if the loop runs to completion it terminatesand any else suite is executed if the loop is broken out of due to break statementor return statement (if the loop is in function or method)or if an exception is raisedthe else clause' suite is not executed (if an exception occurspython skips the else clause and looks for suitable exception handler--this is covered in the next section enumerate( here is for in loop version of the list_find(functionand like the while loop versionit shows the else clause in actiondef list_find(lsttarget)for indexx in enumerate(lst)