Skip to content

Instantly share code, notes, and snippets.

@panchishin
Created July 29, 2021 17:09
Show Gist options
  • Save panchishin/c33c7ddcac24c0a1410a919082aeb9f5 to your computer and use it in GitHub Desktop.
Save panchishin/c33c7ddcac24c0a1410a919082aeb9f5 to your computer and use it in GitHub Desktop.
Very simple text adventure example
def getChoice(choices):
message = "Pick one of : " + ", ".join(choices) + " > "
choice = ""
while choice not in choices:
choice = input(message)
print()
return choice
if __name__ == "__main__":
print()
print("You are in a room with 2 exists, north and south. You smell something horrible to the south and a warm light comes from the north. Which way do you go?")
decision = getChoice(['north','south'])
if (decision == 'north'):
print("The warm light turned out to be an incinerator. You died. Try again")
else :
print("You have entered the sewage pumping station. You see the toxic avenger here. Do you 'fight' or 'wave'?")
decision = getChoice(['fight','wave'])
if (decision == 'fight'):
print("Terrible choice, the toxic avenger never loses. You died. Try again")
else :
print("He is now your friend and shows you the exit. You win.")
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment