and only prints the message if it does not match the quit valuetell me somethingand will repeat it back to youenter 'quitto end the program hello everyonehello everyonetell me somethingand will repeat it back to youenter 'quitto end the program hello again hello again tell me somethingand will repeat it back to youenter 'quitto end the program quit using flag in the previous examplewe had the program perform certain tasks while given condition was true but what about more complicated programs in which many different events could cause the program to stop runningfor examplein gameseveral different events can end the game when the player runs out of shipstheir time runs outor the cities they were supposed to protect are all destroyedthe game should end it needs to end if any one of these events happens if many possible events might occur to stop the programtrying to test all these conditions in one while statement becomes complicated and difficult for program that should run only as long as many conditions are trueyou can define one variable that determines whether or not the entire program is active this variablecalled flagacts as signal to the program we can write our programs so they run while the flag is set to true and stop running when any of several events sets the value of the flag to false as resultour overall while statement needs to check only one conditionwhether or not the flag is currently true thenall our other tests (to see if an event has occurred that should set the flag to falsecan be neatly organized in the rest of the program let' add flag to parrot py from the previous section this flagwhich we'll call active (though you can call it anything)will monitor whether or not the program should continue runningprompt "\ntell me somethingand will repeat it back to you:prompt +"\nenter 'quitto end the program active true while activemessage input(promptw if message ='quit'active false elseprint(message