jabela

Hangman Skeleton

Mar 8th, 2017
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. #Put in a variable for your secret word
  2. word =
  3.  
  4. # Creates a variable with an empty value
  5. guesses = ''
  6.  
  7. # The number of turns
  8. turns = 10
  9.  
  10. #check if the turns are more than zero
  11. while turns > 0:
  12.  
  13.     # make a counter that starts with zero
  14.     failed = 0
  15.     # Create a loop for every character in the secret word.
  16.  
  17.     # see if the character is in the players guess
  18.         if char in guesses:
  19.  
  20.         # print out the character
  21.  
  22.         else:
  23.  
  24.         # if not found, print a dash
  25.  
  26.         # and increase the failed counter with one
  27.             failed += 1
  28.  
  29.     # if failed is equal to zero
  30.  
  31.     # print You Won
  32.     if failed == 0:
  33.         print ("You won")
  34.  
  35.     # exit the script
  36.         break
  37.  
  38.     # ask the user to guess a character
  39.     guess = input(" guess a character:")
  40.  
  41.     # set the players guess to guesses
  42.     guesses += guess
  43.  
  44.     # if the guess is not found in the secret word
  45.     if guess not in word:
  46.  
  47.      # turns counter decreases with 1 (now 9)
  48.         turns -= 1
  49.  
  50.     # print wrong
  51.         print("Wrong")
  52.  
  53.     # how many turns are left
  54.         print("You have", + turns, 'more guesses')
  55.  
  56.     # if the turns are equal to zero
  57.         if turns == 0:
  58.  
  59.         # print "You Lose"
  60.             print("You Lose")
Add Comment
Please, Sign In to add comment