result runlevel(levelscurrentlevelindexthe runlevel(function handles all the action for the game it is passed list of level objectsand the integer index of the level in that list to be played when the player has finished playing the levelrunlevel(will return one of the following strings'solved(because the player has finished putting all the stars on the goals)'next(because the player wants to skip to the next level)'back(because the player wants to go back to the previous level)and 'reset(because the player wants to start playing the current level over againmaybe because they pushed star into corner if result in ('solved''next')go to the next level currentlevelindex + if currentlevelindex >len(levels)if there are no more levelsgo back to the first one currentlevelindex elif result ='back'go to the previous level currentlevelindex - if currentlevelindex if there are no previous levelsgo to the last one currentlevelindex len(levels)- if runlevel(has returned the strings 'solvedor 'next'then we need to increment levelnum by if this increments levelnum beyond the number of levels there arethen levelnum is set back at the opposite is done if 'backis returnedthen levelnum is decremented by if this makes it go below then it is set to the last level (which is len(levels)- elif result ='reset'pass do nothing loop re-calls runlevel(to reset the level if the return value was 'reset'then the code does nothing the pass statement does nothing (like comment)but is needed because the python interpreter expects an indented line of code after an elif statement we could remove lines and from the source code entirelyand the program will still work just the same the reason we include it here is for program readabilityso that if we make changes to the code laterwe won' forget that runlevel(can also return the string 'resetemail questions to the authoral@inventwithpython com