Guest User

Untitled

a guest
Jul 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. from random import *
  2. wordChosen = input("Write a word for someone to guess. ")
  3. list = []
  4. wrong = []
  5. # list.append()
  6. tries = 6
  7. end = 1
  8. for i in range(len(wordChosen)):
  9. list.append("_")
  10. print(list)
  11.  
  12. while(tries > 0):
  13. if(end == len(wordChosen)):
  14. break
  15. else:
  16. guess = input("choose a letter: ")
  17. if(guess in wordChosen):
  18. for i in range((len(wordChosen))):
  19. # if the letter at i = guess replace list num with guess
  20. if(guess == wordChosen[i]):
  21. list[i] = guess
  22. print(list)
  23. end = end + 1
  24. else:
  25. print("try again")
  26. wrong.append(guess)
  27. tries = tries - 1
  28. print("tries: ", tries)
  29. if(tries == 0):
  30. print("game over")
  31. if(end == len(wordChosen)):
  32. print("you won!")
Add Comment
Please, Sign In to add comment