# Author: James Tam # Version: September 21, 2021 # Learning objectives: # Illustrating the advantage of using IF-ELIF when a max. of one condition can # be true. print("""" GAME OPTIONS ------------ (a)dd a pre-generated player (c)reate new player (p)urge player entirely from game (gone forever) (r)emove existing player (player information is saved) (q)uit game """) menuSelection = input("Selection: ") if (menuSelection == "a"): print("Adding player.") if (menuSelection == "c"): print("Creating new player.") if (menuSelection == "p"): print("Caution: A purged player will be gone forever and not retrievable.") print("Are you sure you want to really do this?") if (menuSelection == "r"): print("Removing player and saving current stats.") if (menuSelection == "q"): print("Quiting game, thank you and come again.") #Very awkward to implement the "none of the above" case without an if-eli #JT's note: with python one can employ a if not in () construct - to be covered #in lecture - but this does not exist with many other programming languages #such as C++, Java etc. if ((menuSelection != "a") and \ (menuSelection != "c") and \ (menuSelection != "p") and \ (menuSelection != "r") and \ (menuSelection != "q")): print("Selection must be one of 'a', 'c', 'p', 'r', 'q'")