import random def meadow(): print ("Hello World you are in a bright and \n\ grass covered meadow - you see a cave and a forest in front of you") choice = input("Type cave or forest") if choice == "cave" : print("Ok you are in a cave") cave() elif choice == "forest" : print("Ok you are in a forest now") forest() elif choice == "i" : PrintInventory() meadow() else: print("Wrong choice only forest or cave") meadow() def cave(): print ("Hello World you are in a dark \n\ gloomy cave outside is a meadow you see a small box on the ground") choice = input("Type meadow or Get box or i") if choice == "meadow" : meadow() elif choice == "Get box" : AddToInventory("Small Box") cave() elif choice == "i" : PrintInventory() cave() else: print("Wrong choice only meadow or i") cave() def forest(): options = ["Oak", "Pine", "Elm", "Beech"] print ("Hello World you are in a tall dark " + random.choice(options) + "\n\ forest behind you is a cave to your left is a meadow") choice = input("Type meadow or cave or deep or i") if choice == "meadow" : meadow() elif choice == "cave" : cave() elif choice == "deep" : deep() elif choice == "i" : PrintInventory() forest() else: print("Wrong choice only meadow or cave or i") forest() def deep(): options = ["very dark", "Sinister", "pitch dark", "scary"] print ("Hello World you are in a " + random.choice(options) + " forest \n\ you cannot see anything apart from the glint of a blade") choice = input("Type forest or get knife or i") if choice == "forest" : forest() elif choice == "get knife" : AddToInventory("knife") deep() elif choice == "i" : PrintInventory() deep() else: print("Wrong choice only meadow or cave or i") deep() def PrintInventory(): if not inventory: print("You have nothing") else: print("\n You are Carrying:") print(inventory) def AddToInventory(item): global inventory if item in inventory: print("You already have the " + item + " in the inventory") else: inventory.append(item); inventory = [] meadow()