Guest User

Untitled

a guest
Sep 22nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.47 KB | None | 0 0
  1. print("Welcome to hangman!")
  2. g = open("C:\\Users\\Angela\\Documents\\Python\\word_list.txt", "r")
  3. word = random.choice(g.readlines())[1:]
  4. print("-" * len(word))
  5.  
  6. guess = ""
  7.  
  8. while 1:
  9.     check = 0
  10.     output = ""
  11.  
  12.     print("Guess a letter: ")
  13.     b = input()
  14.     guess += b
  15.     for a in word:
  16.         if a in guess:
  17.             output += a
  18.             check += 1
  19.         else:
  20.             output += "-"
  21.     print(output)
  22.     if check == len(word):
  23.         break
Add Comment
Please, Sign In to add comment