-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
96 lines (94 loc) · 1.5 KB
/
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
import requests
from bs4 import BeautifulSoup
from random import choice
r = requests.get("https://www.vocabulary.com/lists/52473#view=list")
s = BeautifulSoup(r.text, "html.parser")
lst = s.find_all("a", attrs={"class": "word"})
words = choice(lst).text.strip()
out = "_" * len(words)
o2 = list(out)
print("".join(o2))
pics = [
"""
+---+
| |
|
|
|
|
=========""",
"""
+---+
| |
O |
|
|
|
=========""",
"""
+---+
| |
O |
| |
|
|
=========""",
"""
+---+
| |
O |
/| |
|
|
=========""",
"""
+---+
| |
O |
/|\ |
|
|
=========""",
"""
+---+
| |
O |
/|\ |
/ |
|
=========""",
"""
+---+
| |
O |
/|\ |
/ \ |
|
=========""",
]
f = -1
while f != 6:
g = input("Your guess: ")
if g not in words:
f += 1
print(pics[f])
elif words.count(g) == o2.count(g):
f += 1
print(pics[f])
else:
count = []
for i in range(0, len(words)):
if g == words[i]:
count.append(i)
for j in count:
if o2[j] == g:
continue
else:
o2[j] = g
print("".join(o2))
break
if "".join(o2) == words:
print("You won! :)")
break
elif f == 6:
print("You lost! :(")