-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHangman game.py
90 lines (86 loc) · 3.67 KB
/
Hangman game.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
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
import random
name=input("Enter your name: ")
print("Welcome To The World Of Hangman (Movies) ")
print("Try to Guess within '10', All the best!",name)
words=["friends","master","maattrran","teddy","madras","madrasapattinam","jeans","jail","sitaramamam","theri","three","pizza","thegidi","boys","ghajini","pokiri","jilla","ghilli","kaithi","pichaikkaran","beast","sooraraipottru","okkanmani","lovetoday","alaipayuthey","thiruchitrambalam","mersal"]
letters=[]
count=10
choice=random.choice(words).lower()
while count>0 :
global wp
guess=input("Enter your letter: ").lower()
if guess in choice:
letters.append(guess)
wp=""
for letter in choice:
if letter in letters:
wp += letter
else:
wp +=" _ "
print(wp)
if wp == choice:
print("Congragulations",name,"you guessed the correct word !!! ")
print("Enter y to play again, n to stop ")
x=input("Do you want to play again?")
if x=="n":
break
if guess not in choice:
count-=1
if count==9:
print("--Only 9 chances left--")
print(" ---------- ")
elif count == 8:
print("--Only 8 chances left--")
print(" --------- ")
print(" O ")
elif count == 7:
print("--Only 7 chances left--")
print(" --------- ")
print(" O ")
print(" | ")
elif count == 6:
print("--Only 6 chances left")
print(" --------- ")
print(" O ")
print(" | ")
print(" / ")
elif count == 5:
print("--Only 5 chances left--")
print(" --------- ")
print(" O ")
print(" | ")
print(" / \ ")
elif count == 4:
print("-- Only 4 chances left--")
print(" ---------- ")
print(" \ O ")
print(" | ")
print(" / \ ")
elif count== 3:
print("--Only 3 chances left--")
print(" ---------- ")
print(" \ O / ")
print(" | ")
print(" / \ ")
elif count == 2:
print("--Only 2 chances left-")
print(" ---------- ")
print(" \ O / ")
print(" | ")
print(" / \ ")
elif count == 1:
print("Last chance left ")
print(" ---|------ ")
print(" \ O / ")
print(" | ")
print(" / \ ")
elif count == 0:
print(" ---|----- ")
print(" 0 ")
print(" ======== ")
print(" /|\ ")
print(" / \ ")
print("As you left the last chance , the man left the world......")
print("Save the next man, if you can ")
print("The word which killed the man is",choice)
break