-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHangman.py
28 lines (27 loc) · 1.08 KB
/
Hangman.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#Hangman Game
import random #importing random module
import hangman_stages
List_of_words = ['Krishna','Radha','Ram','Ganesh','Shiva','Narayana','Laxmi','Saraswati','Paravti','Sita','Hanuman','Brahma','Sati','Khatushyam','Ganga','Yamuna','Surya','Jagannath','Rameshwaram','Kedarnath','Badrinath'] #Making a list of words!
chosen_word = random.choice(List_of_words) #Choosing a random word from the list
chance=6
result=[]
for i in chosen_word:
result+='_'
while True:
guess_alpha = input("Guess a letter : ") #Guess the Word
for j in range(len(chosen_word)):
alpha=chosen_word[j]
if alpha==guess_alpha:
result[j]=guess_alpha
print(result)
if guess_alpha not in chosen_word:
chance-=1
if chance==0:
print("All your chances are over! You LOSE!")
print(chosen_word)
print(hangman_stages.stages[0])
break
if '_' not in result:
print("You WON!")
break
print(hangman_stages.stages[chance])