-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
41 lines (32 loc) · 985 Bytes
/
code.py
File metadata and controls
41 lines (32 loc) · 985 Bytes
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
import random
import utility
import os
import hangman
random_words = ["word", "india", "potato", "tomato", "pizza"]
max_life = 6
word = random.choice(random_words)
blank_word = '_'*len(word)
checked_letters = []
while True:
os.system('cls')
hangman.draw_logo()
hangman.draw_hangman(max_life)
utility.draw_blanks(blank_word)
inp = input("Guess a letter:")
if inp in word and inp not in checked_letters:
checked_letters.append(inp)
blank_word = utility.fill_blanks(word, blank_word, inp)
if blank_word == word:
utility.game_over("You Won!")
break
else:
continue
else:
max_life = max_life - 1
if max_life == 0:
os.system('cls')
hangman.draw_logo()
hangman.draw_hangman(max_life)
utility.draw_blanks(blank_word)
utility.game_over("You lost.")
break