-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhangmanRMN.py
84 lines (77 loc) · 1.38 KB
/
hangmanRMN.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
from random import choice
words = ['lion','rabbit','dog','cat','pig','chicken','fox']
word = choice(words)
guessed_letters=[]
displayed_word="_"*len(word)
hangmanStages = [
"""
-----
| |
|
|
|
======
""",
"""
-----
| |
O |
|
|
======
""",
"""
-----
| |
O |
| |
|
======
""",
"""
-----
| |
O |
/ | \ |
|
======
""",
"""
-----
| |
O |
/ | \ |
| |
======
""",
"""
-----
| |
O |
/ | \ |
| |
/ \ |
======
""",
]
print ("_"*len(word))
mistakes = 0
def guess_letter():
global mistakes,displayed_word
guess = input("enter your guess letter: ")
while guess in guessed_letters:
guess = input("enter your guess letter: ")
guessed_letters.append(guess)
for i in range(0,len(word)):
if guess == word[i]:
displayed_word = displayed_word[:i]+guess+displayed_word[i+1:]
print (displayed_word)
if guess not in word:
print("wrong guess,try again!")
print(hangmanStages[mistakes])
mistakes += 1
while mistakes < 6:
guess_letter()
if displayed_word == word:
print("you win!")
break