Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.21 KB | None | 0 0
  1. import random
  2. name = input ("Please enter your name ")
  3. print ("➤ Welcome", name,"let's play!")
  4.  
  5. done = False
  6. while not done:
  7.  
  8.  
  9.     words =[]
  10.  
  11.     yes = "Y", "y", "Yes", "yes", "Yes", "Yep", "yep", "YEP", "Yeah", "yeah", "YEAH"
  12.     no = "N", "n", "No", "no", "NO", "Nope", "nope", "NOPE", "nah", "Nah", "NAH"
  13.     addWords = input ("Would you like to add your own words? Y/N: ")
  14.     if addWords in yes:
  15.         end = False
  16.         while end == False:
  17.             new = input("★  Enter new word ")
  18.             words.append(new)
  19.             more = input("✰  Add more words? Y/N: ")
  20.  
  21.             if more in no:
  22.                 end = True
  23.             elif more in yes:
  24.                 end - False
  25.            
  26.  
  27.     #game start
  28.     else:
  29.         addWords in no
  30.         words =["python","elephant","orange","pizza","promgramming","monkey","fingers","horse","england","america","burger"]
  31.     random = random.choice(words)
  32.     guesses = ''
  33.     lives = 5
  34.  
  35.     while lives > 0:
  36.         lostLifes = 0
  37.         for letter in random:
  38.             if letter in guesses:
  39.                 print(letter,)
  40.             else:
  41.                 print ('_',)
  42.                 lostLifes = (lostLifes+1)
  43.                 print
  44.  
  45.         if lostLifes == 0:
  46.             print ("Congratulations", name)
  47.             print ("  ✔ You Won! ✔")
  48.             break
  49.  
  50.         newLetter = False
  51.         while newLetter == False:
  52.             guess = input ("Guess a letter: ")
  53.             if len(guess) > 1:
  54.                 print ("★   You may only guess one letter!")
  55.                 guess = input ("Guess a letter: ")
  56.             if guess in guesses:
  57.                 print("✰    You already guessed that letter")
  58.             else:
  59.                 guesses += guess
  60.                 newLetter = True
  61.  
  62.         if guess not in random:
  63.             lives = (lives -1)
  64.             print ("✖ Lost a life")
  65.             print ("Only", lives, "lives left.")
  66.             print ("➤ Used letters:", guesses,)
  67.             if lives == 0:
  68.                 print ("  ✖ YOU LOST! ✖")
  69.                 print ("The answer was", random)
  70.  
  71.     input = done("➤  Try again? Y/N: ")
  72.     if input in no:
  73.         done = True
  74.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement