-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLessGo.py
More file actions
59 lines (40 loc) · 1.16 KB
/
Copy pathLessGo.py
File metadata and controls
59 lines (40 loc) · 1.16 KB
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
import random
from hangman_words import word_list
from hangman_art import logo
from hangman_art import stages
print(logo)
chosen_one = random.choice(word_list)
word_list= len(chosen_one)
print(word_list)
placeholder = ""
for position in range(word_list):
placeholder+="_"
print(placeholder)
number_of_lives = 6
game_over = False
correct_letters=[]
while not game_over:
print(f"****{number_of_lives}/6 left**** ")
guess = input("Guess a letter: ").lower()
if guess in correct_letters:
print(f"YOU HAVE ALREADY GUESSED {guess}")
display = ""
for letter in chosen_one:
if letter == guess:
display += letter
correct_letters.append(guess)
elif letter in correct_letters:
display += letter
else:
display += "_"
print(display)
if guess not in chosen_one:
number_of_lives-= 1
print(f"YOU GUESSED {guess} THAT'S WRONG")
if number_of_lives == 0:
game_over = True
print(f"YOU LOSE; IT WAS {chosen_one}")
if "_" not in display:
game_over = True
print("YOU WIN")
print(stages[number_of_lives])