pygame display update(fpsclock tick(fpsfor alpha in range( -animationspeed)dimming checkforquit(displaysurf blit(origsurf( )flashsurf fill((rgbalpha)displaysurf blit(flashsurfrectangle topleftpygame display update(fpsclock tick(fpsbut notice that the code inside the for loops handles drawing the frame and are identical to each other if we wrote the code like the abovethen the first for loop would handle the brightening part of the animation (where the alpha value goes from to and the second for loop would handle the dimming part of the animation (where the alpha values goes from to note that for the second for loopthe third argument to the range(call is negative number whenever we have identical code like thiswe can probably shorten our code so we don' have to repeat it this is what we do with the for loop on line which supplies different values for the range(call on line for startendstep in (( )( - ))animation loop for alpha in range(startendanimationspeed step)on the first iteration of line ' for loopstart is set to end is set to and step is set to this waywhen the for loop on line is executedit is calling range( animationspeed(note that animationspeed is the same as animationspeed multiplying number by gives us the same number line ' for loop then executes and performs the brightening animation on the second iteration of line ' for loop (there are always two and only two iterations of this inner for loop)start is set to end is set to and step is set to - when the line ' for loop is executedit is calling range( -animationspeed(note that animationspeed - evaluates to -animationspeedsince multiplying any number by - returns the negative form of that same number this waywe don' have to have two separate for loops and repeat all the code that is inside of them here' the code again that is inside line ' for loop checkforquit(displaysurf blit(origsurf( )flashsurf fill((rgbalpha)