-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (34 loc) · 1.01 KB
/
main.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
import random
from aasci_art import stages, main_logo
word_list = ["mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune"]
print(main_logo)
print("Welcome to the Hangman Game!, Here words are based on planets of our solar system.")
word = random.choice(word_list)
display = []
for letter in word:
display.append("_")
print(display)
endgame = False
life = 6
while not endgame:
guess = input("Guess a letter: ").lower()
for position in range(len(word)):
letter = word[position]
if letter == guess:
print("Correct!")
display[position] = letter
print(display)
if "_" not in display:
endgame = True
print("You win!")
elif guess not in word:
life -= 1
print("Wrong guess.")
print("Remaining lives:", life)
if life == 0:
endgame = True
print("You lose!")
print(stages[life])
print(f" The word was {word}")
break
print(stages[life])