-
Notifications
You must be signed in to change notification settings - Fork 1
/
Hangman.py
48 lines (35 loc) · 876 Bytes
/
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
import time
import random
word_list = ["school","car","book"]
word = random.choice(word_list)
#print(word[0])
word_length = len(word)
#print(word_length)
dash_list = []
for letter in word:
dash_list.append("-")
print(dash_list)
life=8
while True:
guess = input("Type a letter :")
if guess in word:
b=0
for letter in word:
if guess == letter:
dash_list[b] = guess
else:
pass
b+=1
print(dash_list)
else:
print(dash_list)
life-=1
print("False")
print(f"Your have {life} lives")
if life==0:
print("You lost :(")
break
if "-" not in dash_list:
print("You won :)")
break
time.sleep