Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. def word(word):
  2. tries = 6
  3. output = ['_' for i in range(len(word))]
  4. blankLeft = len(word)
  5. while tries > 0:
  6. tries -= 1
  7. guessedWord = input('Enter your letter: ')
  8. if guessedWord == word:
  9. return print('you won !')
  10. for i in range(len(word)):
  11. for letter in guessedWord:
  12. if word[i] == letter:
  13. output[i] = letter
  14. blankLeft -= 1
  15. if blankLeft <= 0:
  16. return print("".join(output), '\nyou won !')
  17. print("".join(output), "\n you have ", tries, " tries left")
  18.  
  19. word('try')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement