Advertisement
Guest User

Hangman

a guest
Apr 1st, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.85 KB | None | 0 0
  1. #HANGMAN
  2. from turtle import*
  3.  
  4. #gallow
  5. ht()
  6. pensize(6)
  7. pu()
  8. lt(90)
  9. fd(100)
  10. pd()
  11. fd(20)
  12. rt(90)
  13. fd(100)
  14. rt(90)
  15. fd(300)
  16. lt(90)
  17. fd(10)
  18. rt(180)
  19. fd(200)
  20. pu()
  21. home()
  22. sety(100)
  23. pd()
  24. lt(180)
  25. pensize(3)
  26.  
  27.  
  28. word = list(input('Enter a word: '))
  29. guess = []
  30. wrong = []
  31. ind = 0
  32. att = 0
  33. fail = 0
  34.  
  35. for i in range(40):
  36.     print('.')
  37. print('Start!')
  38. for i in range(len(word)):
  39.     guess += '_'
  40. print(*guess)
  41.  
  42. while True:
  43.     letter = input('Enter a letter: ')
  44.     if letter in word:
  45.         print('Correct letter')
  46.         while ind < len(word):
  47.             if letter == word[ind]:
  48.                 guess[ind] = letter
  49.             ind += 1
  50.         att += 1
  51.     else:
  52.         wrong.append(letter)
  53.         att += 1
  54.         fail += 1
  55.         print('Wrong letter')
  56.  
  57.         if fail == 1:
  58.             circle(30)
  59.  
  60.         elif fail == 2:
  61.             pu()
  62.             lt(90)
  63.             fd(60)
  64.             pd()
  65.             fd(100)
  66.  
  67.         elif fail == 3:
  68.             pu()
  69.             bk(70)
  70.             rt(110)
  71.             pd()
  72.             fd(60)
  73.  
  74.         elif fail == 4:
  75.             pu()
  76.             rt(180)
  77.             fd(60)
  78.             rt(320)
  79.             pd()
  80.             fd(60)
  81.  
  82.         elif fail == 5:
  83.             pu()
  84.             rt(180)
  85.             fd(60)
  86.             lt(70)
  87.             fd(70)
  88.             pd()
  89.             rt(35)
  90.             fd(75)
  91.            
  92.         elif fail == 6:
  93.             pu()
  94.             rt(180)
  95.             fd(75)
  96.             rt(105)
  97.             pd()
  98.             fd(75)
  99.             print('Game over. The word was:', *word)
  100.             break
  101.     print(*guess)
  102.     if len(wrong) > 0:
  103.         print('Wrong letters:', *wrong)
  104.     print('_________________________________')
  105.     ind = 0
  106.     if guess.count('_') == 0:
  107.         print('You guessed the word in',att,'tries')
  108.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement