Code: Select all
def get_hangman_stage(remaining_attempts):
stages = [
r"""
_______
| |
|
|
|
__|__
""",
r"""
_______
| |
0 |
|
|
__|__
""",
r"""
_______
| |
0 |
| |
|
__|__
""",
r"""
_______
| |
0 |
| |
/ |
__|__
""",
r"""
_______
| |
0 |
| |
/ \ |
__|__
""",
r"""
_______
| |
0 |
-| |
/ \ |
__|__
""",
r"""
_______
| |
0 |
-|- |
/ \ |
__|__
""",
r"""
_______
| |
0 |
--|- |
/ \ |
__|__
""",
r"""
_______
| |
O |
--|-- |
/ \ |
__|__
"""
]
print(stages[stage])
import random
words = ["computer", "pineapple", "table", "school", "walking"]
random.shuffle(words)
word = words[1]
stage = 0
noc = 0
for char in word:
if char.isalpha:
noc += 1
get_hangman_stage(remaining_attempts=+1)
print(noc,"digits")
count = 0
guesses = []
while count < noc:
guess = input("Guess a letter")
guesscount = word.count(guess)
if stage == 8:
get_hangman_stage(remaining_attempts=+1)
break
else:
if guess in word:
print(guesscount,guess)
count =+ 1
get_hangman_stage(remaining_attempts=+1)
else:
print("no",guess)
stage =+ 1
get_hangman_stage(remaining_attempts=+1)
continue
while True:
if stage == 8:
print("Game over")
break
else:
fullguess = input("Guess the word")
if fullguess == word:
print("You Win!")
else:
stage =+1
if not stage == 8:
print("Try again")
continue
Mobile version