-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhangman_game.py
112 lines (105 loc) · 2.8 KB
/
hangman_game.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
from randomdfv import list1
import random
from time import sleep
from os import system, name
# created by Avijit roy
def clear():
# for windows
if name == 'nt':
_ = system('cls')
# for mac and linux(here, os.name is 'posix')
else:
_ = system('clear')
def situation(dj):
if dj == 1:
print("guess the word:...!")
print("you have", x, "chance: ")
print(" +---+")
print(" |")
print(" |")
print(" |")
print(" , ,====")
elif dj == 2:
print("guess the word:.....!")
print("you have", x, "chance left: ")
print(" +---+")
print(" O |")
print(" |")
print(" |")
print(" , ,====")
elif dj == 3:
print("guess the word:.....!")
print("you have", x, "chance left: ")
print(" +---+")
print(" O |")
print(" | |")
print(" |")
print(" , ,====")
elif dj == 4:
print("guess the word:......!")
print("you have", x, "chance left: ")
print(" +---+")
print(" O |")
print(" |\ |")
print(" |")
print(" , ,====")
elif dj == 5:
print("guess the word:.....!")
print("you have", x, "chance left: ")
print(" +---+")
print(" O |")
print(" /|\ |")
print(" |")
print(" , ,====")
elif dj == 6:
print("guess the word:.....!")
print("you have last chance: ")
print(" +---+")
print(" O |")
print(" /|\ |")
print(" / |")
print(" , ,====")
elif dj == 7:
print(" +---+")
print(" O |")
print(" /|\ |")
print(" / \ |")
print(" , ,====")
print("you lost: \n\tthe word was", word)
td = "y"
while td.lower() == "y":
word = random.choice(list1)
m = 1
x = 6
do = []
doi = []
dis = []
for k in range(len(word)):
dis.append("_")
print(dis)
situation(m)
for i in word:
doi.append(i)
print("_"*len(do), "\n")
while m <= 6:
a = input("enter the word: ")
if a in doi and a not in do:
dis[word.index(a)] = a
print(dis)
situation(m)
do.append(a)
if sorted(doi) == sorted(do):
print("you win...")
print("\tthe word was", word)
m = 7
else:
print(dis)
print("wrong answer....!")
m += 1
x -= 1
situation(m)
clear()
sleep(5)
td = input("wanna play again y/n: ")
else:
exit()