state pattern player action(chr(ch)print(player statetime sleep( if __name__ ="__main__"main(how do you feel about the altered codewhat do you like about itwhat have you learnedwhat do you think can be improvedi want to encourage you to begin looking at code online and asking yourself these questions you will often find you learn more from reading other people' code than from all the tutorials you could ever find online that is also the point where you take another big step forward in your learningwhen you begin to think critically about the code you find online rather than just copying it into your project and hoping for the best parting shots in this we discovered how closely we could link actual code in python to an abstract tool for solving multiple types of problemsnamely the state machine all state machines are composed of states and the transitions taking the machine from one state to another based on certain inputs usuallythe state machine will also execute some actions while in state before transitioning to another state we also looked at the actual code you could use to build your very own state machine in python here are some quick and simple ideas for constructing your own state machinebased solutions identify the states your machine can be insuch as running or walking orin the case of traffic lightredyellowand green identify the different inputs you expect for each state draw transition from the current state to the next state based on the input note the input on the transition line define the actions taken by the machine in each state abstract the shared actions into the base state class implement concrete classes for each state you identified