-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhungman.py
33 lines (28 loc) · 810 Bytes
/
hungman.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
29
30
31
32
33
import random
print("\t*** HUNGMAN GAME ***\n")
movies = ['pushpa', 'avengers', 'bahubali', 'avtar', 'pathan', 'mission impossible']
one_movie = list(random.choice(movies).lower())
chance = 5
s = ["_ " for i in one_movie]
print("Guess the Movie name: ")
print(" ".join(s))
while chance != 0:
print(f"\tyou have {chance} chance left.")
ch = input("\nGuess the Movie name: ").lower()
if ch not in one_movie:
print("you have guessed wrong...!!")
chance -= 1
print(" ".join(s))
continue
j = 0
for i in one_movie:
if i == ch:
s.pop(j)
s.insert(j, ch)
j += 1
print(" ".join(s))
if s == one_movie:
print("\n\tYou *** WIN *** the Game.... !!!")
break
else:
print("\n\tYou loose the Game..!!")