PWD MP
PWD MP
Code
# Python Program to illustrate
# Hangman Game
Import random
someWords = someWords.split(‘ ‘)
# randomly choose a secret word from our “someWords” LIST.
Word = random.choice(someWords)
If __name__ == ‘__main__’:
Print(‘_’, end=’ ‘)
Print()
Playing = True
letterGuessed = ‘’
chances = len(word) + 2
correct = 0
flag = 0
try:
while (chances != 0) and flag == 0: # flag is updated when
the word is correctly guessed
print()
chances -= 1
try:
except:
continue
Continue
Continue
Continue
K = word.count(guess)
For _ in range(k):
Print(char, end=’ ‘)
Correct += 1
Print(word)
Flag = 1
Else:
Print(‘_’, end=’ ‘)
Except KeyboardInterrupt:
Print()
Print(‘Bye! Try again.’)
Exit()
Output