2nd Game.
import random from time import sleep def displayintro(): print("It's been a long time fighting.") sleep(1) print("You come to a crossroads.") sleep(1) print("You have two paths you can choose.") sleep(1) print('One will lead to victory one will lead to dismay.') print() def choosepath(): path = "" while path != "1" and path != "2": path = input('What path do you choose? (1 or 2)') return path def checkpath(chosenpath): print("You head to down the path.") sleep(1) print("There is a battle ahead.") correctPath = random.randint(1,2) if chosenpath == str(correctPath): print("You win the battle and head home!") else: print("You lost and are forgotten in time.") playagain = "Yes" while playagain == "Yes" or playagain == "y": displayintro() choice = choosepath() checkpath(choice) playagain = input("Do you want to play again? (y or n)")
/Users/mattfassnacht/PycharmProjects/classesobjects/venv/bin/python /Users/mattfassnacht/PycharmProjects/classesobjects/code.py
It's been a long time fighting.
You come to a crossroads.
You have two paths you can choose.
One will lead to victory one will lead to dismay.
What path do you choose? (1 or 2)1
You head to down the path.
There is a battle ahead.
You lost and are forgotten in time.
Do you want to play again? (y or n)y
It's been a long time fighting.
You come to a crossroads.
You have two paths you can choose.
One will lead to victory one will lead to dismay.
What path do you choose? (1 or 2)1
You head to down the path.
There is a battle ahead.
You win the battle and head home!
Do you want to play again? (y or n)n
Process finished with exit code 0
Comments