Advertisement
Benedictus

List_Use

Dec 13th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. import random
  2. import time
  3.  
  4. def display():
  5.   print("You're on your way home and you come to a crossroad.")
  6.   print("One path leads you home and the other leads to a very dangerous place where the unknown creatures live.")
  7.   print()
  8.  
  9. def choosepath():
  10.   path = ''
  11.   while path != '1' and path != '2':
  12.     path = input("Which path will you choose? '1' or '2': ")
  13.   return path
  14.  
  15. def checkpath(chosenpath):
  16.   print("You head down the path,")
  17.   print("but you're not sure where it takes you.")
  18.   time.sleep(3)
  19.   print()
  20.   list1 = [1,2]
  21.   correctpath = random.randint(*list1)
  22.   print(correctpath)
  23.   if int(chosenpath) == (correctpath):
  24.     print("You're safe and you made it home!")
  25.     print("You choose the right path.")
  26.     print()
  27.   else:
  28.     print("A monster running your way.")
  29.     print("It might attack you and get yourself killed.")
  30.     time.sleep(3)
  31.     print("\nYou're dead! \nYou choose the wrong path.")
  32.     print()
  33.  
  34. def game():
  35.   play = True
  36.   while play == True:
  37.     display()
  38.     choice = choosepath()
  39.     checkpath(choice)
  40.     playagain = input("Do you want to play again (Yes or No?): ")
  41.     if playagain == "yes" or playagain == "Yes":
  42.       play = True
  43.     elif playagain == "no" or playagain == "No":
  44.       play = False
  45.       print("\nAdventure ends.")
  46.      
  47.      
  48.  
  49. game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement