-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHangman.py
70 lines (70 loc) · 1.37 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
import random
print("WELCOME Lets Start The Game\n🤝🏻 Good Luck ! ")
words = ["table fan","entry door","table mat","bed sheet","mechine chair","robotic car","refridgerator","football","basket ball" ]
word=random.choice(words)
hangman= ['''
+---+
|
|
|
===''', '''
+---+
O |
|
|
|
=====''', '''
+---+
O |
| |
|
|
=====''', '''
+---+
O |
/| |
|
|
=====''', '''
+---+
O |
/|\ |
| |
|
=====''', '''
+---+
O |
/|\ |
/ |
|
=====''', '''
+---+
O |
/|\ |
/ \ |
|
=====''']
guesses =''
turns = 7
print('guess the word = ',end="")
while turns > 0:
fails = 0
for char in word:
if char in guesses:
print(char)
else:
print("_",end="")
fails += 1
if fails == 0:
print("THE WORD YOU GUESSED IS CORRECT")
print("The word is: ", word)
break
guess = input("\nguess the word:")
guesses += guess
if guess not in word:
turns -= 1
print(hangman[turns-1])
print("entered word is Wrong")
print("the remaining ", + turns, 'are left')
if turns == 0:
print("THE WORD YOU GUESSED IS INCORRECT")