-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHangman.py
More file actions
43 lines (31 loc) · 736 Bytes
/
Hangman.py
File metadata and controls
43 lines (31 loc) · 736 Bytes
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
import random
words = ['morocco', 'spain', 'egypt', 'poland', 'japan']
random_word = random.choice(words)
display=[]
for word in random_word:
display.append("_")
print(display)
lives = 6
while "_" in display and lives>0:
guess = input("Please guess a letter:").lower()
if guess not in random_word:
lives -=1
for position in range(len(random_word)):
if random_word[position] == guess:
display[position] = guess
print(display)
print(f"You have {lives} more tries")
if lives ==0:
print("""
******You!Lose!!
+---+
| |
O |
/|\ |
/ \ |
|
=========
""")
else:
print("""
*****You!Won*****""")