Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. def bot():
  5.  
  6. def hangman():
  7. def random_line(file):
  8. lines = open(file).read().splitlines()
  9. return random.choice(lines)
  10.  
  11. word = random_line('file.txt')
  12.  
  13. letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  14.  
  15. guess = ''
  16.  
  17.  
  18. while len (word) > 0 :
  19. msg = ""
  20.  
  21. for letter in word :
  22. if letter in guess :
  23. msg = msg + letter
  24.  
  25.  
  26. if msg == word :
  27. print(msg)
  28. print("The word was :",word)
  29. break
  30.  
  31. print(" Ghiceste cuvantul:",msg)
  32.  
  33. guessss = input()
  34.  
  35. if guessss in letters :
  36. guess = guess + guessss
  37. else:
  38. print(" Gresit. Introdu o alta litera :")
  39. guess = input()
  40. hangman()
  41.  
  42. bot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement