JkSoftware

Hangman.py

Nov 10th, 2021 (edited)
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. import random
  2. import hangmanart
  3. import hangmanword
  4.  
  5.  
  6.  
  7.  
  8. endgame = False
  9. hangword = random.choice(hangmanword.wordlist)
  10. blankword = []
  11. lives = 6
  12. stage = 5
  13.  
  14. print(hangmanart.logo)
  15.  
  16.  
  17.  
  18. for letter in hangword:
  19.     blankword.append("_ ")
  20. while not endgame:
  21.     print(blankword)
  22.     userguess = input("Guess a letter ").lower()
  23.     for position in range(len(hangword)):
  24.         letter = hangword[position]
  25.         if letter == userguess:
  26.             print("Right!")
  27.             blankword[position] = letter
  28.     if userguess not in hangword:
  29.         lives -= 1
  30.         print(hangmanart.stages[stage])
  31.         stage -=1
  32.         if lives == 0:
  33.             print("You Lose!")
  34.             endgame = True
  35.     if "_ " not in blankword:
  36.         endgame = True
  37.         print("You Win!")
Add Comment
Please, Sign In to add comment