-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhangman.py
134 lines (118 loc) · 2.9 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
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
import random
def hangman_graphic(guesses):
if guesses == 0:
print " "
print " "
print "________ "
print "| "
print "| "
print "| "
print "| "
print "| "
elif guesses == 1:
print " "
print " "
print "________ "
print "| | "
print "| "
print "| "
print "| "
print "| "
elif guesses == 2:
print " "
print " "
print "________ "
print "| | "
print "| 0 "
print "| "
print "| "
print "| "
elif guesses == 3:
print " "
print " "
print "________ "
print "| | "
print "| 0 "
print "| / "
print "| "
print "| "
elif guesses == 4:
print " "
print " "
print "________ "
print "| | "
print "| 0 "
print "| /| "
print "| "
print "| "
elif guesses == 5:
print " "
print " "
print "________ "
print "| | "
print "| 0 "
print "| /|\ "
print "| "
print "| "
elif guesses == 6:
print " "
print " "
print "________ "
print "| | "
print "| 0 "
print "| /|\ "
print "| / "
print "| "
elif guesses == 7:
print " "
print " "
print "________ "
print "| | "
print "| 0 "
print "| /|\ "
print "| / \ "
print "| "
words=["refrigerator","Conservatorium","autosuggestionist","giovanni","outrivalled"
"mastoparietal", "diakonikon","overdredge","irresoluteness","liverishness"
"downer","spoilt","exsiccator",
"synechia","nonpromiscuous", "procrastinator", "ruthlessness", "bewilderment"]
word=random.choice(words)
#print word
abc=int(len(word))
print "Please Enter Your Name!!!!!"
name=raw_input()
print "Hello,%s Welcome To Hangman!!!"%name
print
print
alpha="abcdefghijklmnopqrstuvwxyz"
guesses=-1
answer="aeiou"
while guesses<8:
mylen=0
for i in word:
if i in answer:
print i,
mylen=mylen+1
else:
print "_",
if (mylen==abc):
print "You Win"
break
hangman_graphic(guesses)
print
print "Please Enter A Letter"
x=raw_input()
#print x
if x in answer:
print "You Have Already Entered"
elif x not in alpha:
print "Please Enter A Valid Character"
else:
answer+=x
if(x not in word):
guesses=guesses+1
print "You Entered A Wrong Character"
elif(x in word):
print "Woohoo!!You Guesses A Correct Letter"
if (guesses==8):
print "You Lost"