forked from thisisshub/HacktoberFest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEn19cs306027_Lovesh_Kumrawat_HangMan_Game
207 lines (192 loc) · 8.63 KB
/
En19cs306027_Lovesh_Kumrawat_HangMan_Game
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# Program for HangMan Game.
import random
names=['Aaina', 'Aaliyah', 'Aasha', 'Aasiya', 'Abhijeet', 'Aditi', 'Aditya', 'Aishwarya', 'Akshat', 'Amanpreet', 'Amena', 'Amitava', 'Aniruddh', 'Anjali', 'Antara', 'Anubhav', 'Aparna', 'Arjun', 'Armaan', 'Arshpreet', 'Aruna', 'Arunima', 'Arzoo', 'Ashish', 'Ayesha', 'Azad', 'Bahaar', 'Bhagyashree', 'Bhaskar', 'Bhavesh', 'Bhavin', 'Bhavna', 'Bhoomi', 'Bipasha', 'Bipin', 'Chaaya', 'Chandrika', 'Chetas', 'Chhavi', 'Chirag', 'Chiranjeev', 'Chitragandha', 'Daanish', 'Dalbir', 'Daljeet', 'Debashish', 'Debyendu', 'Deepika', 'Devika', 'Dhruv', 'Dipankar', 'Diya', 'Ehsaan', 'Ekta', 'Emir', 'Falguni', 'Farah', 'Fardeen', 'Farhan', 'Fatima', 'Gagandeep', 'Garima', 'Gauhar', 'Gaurav', 'Gautam', 'Gayatri', 'Geetha', 'Girish', 'Gurdeep', 'Gurleen', 'Harbhajan', 'Harini', 'Harpreet', 'Himmat', 'Imraan', 'Indrani', 'Indranuj', 'Ira', 'Jasleen', 'Jayant', 'Jayanti', 'Jayesh', 'Jeet', 'Junaid', 'Jyothsna', 'Jyotiraditya', 'Kabir', 'Kalyani', 'Kanika', 'Kartik', 'Karun', 'Kavya', 'Khalid', 'Kshitij', 'Kuwarjeet', 'Laila', 'Lathika', 'Lavanya', 'Leela', 'Lohith', 'Lopamudra', 'Lovesh', 'Madhav', 'Mahrukh', 'Malavika', 'Manju', 'Maya', 'Meera', 'Meher', 'Mohammed', 'Mridul', 'Naaz', 'Nagma', 'Nalini', 'Nargis', 'Navjot', 'Nikhil', 'Nimit', 'Nishith', 'Nivedita', 'Noor', 'Ojas', 'Om', 'Onkar', 'Paramjit', 'Parinaaz', 'Paritosh', 'Parizaad', 'Parth', 'Parvez', 'Pavan', 'Piya', 'Pooja', 'Prabhjot', 'Pranav', 'Preet', 'Purab', 'Ramandeep', 'Rangana', 'Rasika', 'Rehaan', 'Revati', 'Rihana', 'Rohan', 'Ruchika', 'Sabina', 'Sahil', 'Saira', 'Salman', 'Samarth', 'Samir', 'Sanchit', 'Sanjana', 'Sanjay', 'Santosh', 'Sarabjit', 'Sarah', 'Shaheen', 'Shahnaz', 'Shahzad', 'Shantanu', 'Shereen', 'Shifa', 'Shishir', 'Shivani', 'Shray', 'Shreya', 'Shridevi', 'Shweta', 'Siddharth', 'Simran', 'Sonal', 'Sparsh', 'Sumer', 'Surabhi', 'Surjan', 'Swapan', 'Taahira', 'Tanvi', 'Tara', 'Tarun', 'Tavleen', 'Tejas', 'Tushar', 'Udit', 'Uma', 'Umang', 'Umar', 'Upasana', 'Urvashi', 'Vaishnavi', 'Varun', 'Veer', 'Vidu', 'Vina', 'Yamini', 'Yash', 'Yoshita', 'Zahra', 'Zainab', 'Zeesha', 'ZoyaAngad', 'Zubi']
won='''
_______ _______
\\ / | | | | \\ / | | |\\ |
\\ / | | | | \\ / | | | \\ |
\\ / | | | | \\ /\\ / | | | \\ |
| | | | | \\ / \\ / | | | \\ |
| | | | | \\ / \\ / | | | \\ |
| |_______| |_______| \\/ \\/ |_______| | \\|
'''
lose='''
_______ _______ _______ _______
\\ / | | | | | | | | | |
\\ / | | | | | | | | |
\\ / | | | | | | | |_______ |_______
| | | | | | | | | |
| | | | | | | | | |
| |_______| |_______| |_______ |_______| |_______| |_______
'''
draw=[
"""
_______________
| |
| |
| |
|
|
|
|
|
|
|
|
________|________
"""
,
"""
_______________
| |
| |
| ___|___
| | |
| |___ ___|
| |
| \\ | /
| \\ | /
| \\|/
| / \\
| / \\
________|________ / \\
"""
,
"""
_______________
| |
| |
| ___|___
| | |
| |___ ___|
| |
| \\ | /
| \\ | /
| \\|/
| \\
| \\
________|________ \\
"""
,
"""
_______________
| |
| |
| ___|___
| | |
| |___ ___|
| |
| \\ | /
| \\ | /
| \\|/
|
|
________|________
"""
,
"""
_______________
| |
| |
| ___|___
| | |
| |___ ___|
| |
| | /
| | /
| |/
|
|
________|________
"""
,
"""
_______________
| |
| |
| ___|___
| | |
| |___ ___|
| |
| |
| |
| |
|
|
________|________
"""
,
"""
_______________
| |
| |
| ___|___
| | |
| |___ ___|
|
|
|
|
|
|
________|________
"""
]
while True:
chances=6
inp_lst=[]
result_lst=[]
name=random.choice(names).upper()
# print(name)
[result_lst.append('__ ') for i in range(len(name))]
result_str=str().join(result_lst)
print(f'\nYou have to Guess a Human Name of {len(name)} Alphabets:\t{result_str}')
print(draw[0])
while True:
if result_str.replace(' ','')==name:
print(f'\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Correct Answer: {name} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
print(won+'\a')
break
inp=input('\nGuess an Alphabet or a Sequence of Alphabets: ').upper()
if inp in inp_lst:
print('......................................................................Already Tried')
continue
else:
inp_lst.append(inp)
t=0
indx=[]
if inp in name:
temp=name
while temp!='':
if inp in temp:
indx.append(t+temp.index(inp))
t=temp.index(inp)+1
temp=temp[t:]
else:
break
for j in range(len(indx)):
for i in range(len(inp)):
result_lst[indx[j]]=inp[i]+' '
indx[j]+=1
i+=1
result_str=str().join(result_lst)
print('\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Excellent~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
print(f'\nYou have to Guess a Human Name of {len(name)} Alphabets:\t{result_str}\n')
print('Tried Inputs:',tuple(sorted(set(inp_lst))))
else:
print('\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Try Again!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
print(f'\nYou have to Guess a Human Name of {len(name)} Alphabets:\t{result_str}\n')
print(draw[chances])
chances=chances-1
if chances!=0:
print('Tried Inputs:',tuple(sorted(set(inp_lst))))
print(f'\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You were left with {chances} Chances~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
else:
print(f'\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Correct Answer: {name} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
print(lose+'\a')
break
try:
if int(input('To play the Game Again Press "1" & "0" to Quit: '))!=1:
exit('\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Thank You~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
except:
exit('\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Thank You~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')