Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import *
- wordChosen = input("Write a word for someone to guess. ")
- list = []
- wrong = []
- # list.append()
- tries = 6
- end = 1
- for i in range(len(wordChosen)):
- list.append("_")
- print(list)
- while(tries > 0):
- if(end == len(wordChosen)):
- break
- else:
- guess = input("choose a letter: ")
- if(guess in wordChosen):
- for i in range((len(wordChosen))):
- # if the letter at i = guess replace list num with guess
- if(guess == wordChosen[i]):
- list[i] = guess
- print(list)
- end = end + 1
- else:
- print("try again")
- wrong.append(guess)
- tries = tries - 1
- print("tries: ", tries)
- if(tries == 0):
- print("game over")
- if(end == len(wordChosen)):
- print("you won!")
Add Comment
Please, Sign In to add comment