Skip to content

Instantly share code, notes, and snippets.

@horstjens
Created June 17, 2023 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horstjens/c526f99c3047f4b851384d42b3f766b2 to your computer and use it in GitHub Desktop.
Save horstjens/c526f99c3047f4b851384d42b3f766b2 to your computer and use it in GitHub Desktop.
import random
words = [
"teacher",
"classroom",
"window",
"door",
"tree",
"light",
"table",
"cupboard",
"cable",
"computer",
"mouse",
"monitor",
"camera",
"headphones",
"paper",
]
images = [
r"""
=============================
""",
r"""
____________
/ \
/ \
=============================
""",
r"""
|
|
|
|
|
____________
/ \
/ \
=============================
""",
r"""
+----
|
|
|
|
____________
/ \
/ \
=============================
""",
r"""
_____
| /
|/
|
|
____________
/ \
/ \
=============================
""",
r"""
_____
| / !
|/
|
|
____________
/ \
/ \
=============================
""",
r"""
_____
| / !
|/ O
|
|
____________
/ \
/ \
=============================
""",
r"""
_____
| / !
|/ O
| I
|
____________
/ \
/ \
=============================
""",
r"""
_____
| / !
|/ 0
| /I
|
____________
/ \
/ \
=============================
""",
r"""
_____
| / !
|/ 0
| /I\
|
____________
/ \
/ \
=============================
""",
r"""
_____
| / !
|/ 0
| /I\
| /
____________
/ \
/ \
=============================
""",
r"""
_____
| / !
|/ 0
| /I\
| / \
____________
/ \
/ \
=============================
""",
]
secret = random.choice(words)
hits = []
misses = []
i = 0
while set(hits) < set(secret):
print(images[i])
print("hits :", hits)
print("misses:", misses)
for char in secret:
if char in hits:
print(char, end="")
else:
print(".", end="")
print()
while True:
command = input("guess a letter: >>>")
if len(command.strip()) != 1:
print("one letter please")
continue
break
if command.lower() in secret.lower():
if command.lower() not in hits:
hits.append(command.lower())
else:
misses.append(command)
i += 1
print(hits)
print("Game Over")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment