we can do this by setting the clickedbutton variable to the value in the constant variable yellow we can do the same for the three other keys this waythe user can play simulate with either the mouse or keyboard the two states of the game loop if not waitingforinputplay the pattern pygame display update(pygame time wait( pattern append(random choice((yellowblueredgreen))for button in patternflashbuttonanimation(buttonpygame time wait(flashdelaywaitingforinput true there are two different --modes|or --states|that the program can be in when waitingforinput is falsethe program will be displaying the animation for the pattern when waitingforinput is truethe program will be waiting for the user to select buttons lines to will cover the case where the program displays the pattern animation since this is done at the start of the game or when the player finishes patternline will add random color to the pattern list to make the pattern one step longer then lines to loops through each of the values in the pattern list and calls flashbuttonanimation(which makes that button light up after it is done lighting up all the buttons in the pattern listthe program sets the waitingforinput variable to true figuring out if the player pressed the right buttons elsewait for the player to enter buttons if clickedbutton and clickedbutton =pattern[currentstep]pushed the correct button flashbuttonanimation(clickedbuttoncurrentstep + lastclicktime time time(if waitingforinput is truethen the code in line ' else statement will execute line checks if the player has clicked on button during this iteration of the game loop and if that button was the correct one the currentstep variable keeps track of the index in the pattern list for the button that the player should click on next