Skip to content

Commit 6df6c1a

Browse files
authored
Add files via upload
1 parent d42f26c commit 6df6c1a

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

HangnamGame/main.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import random
2+
import stages_file
3+
lives = 6
4+
word =""
5+
word_list = ['apple','mango','orange','papaya','cricket','football','goa','mumbai','love']
6+
chosen_word = random.choice(word_list)
7+
8+
display = []
9+
for i in range(len(chosen_word)):
10+
display += '_'
11+
12+
game_over = False
13+
while not game_over :
14+
guess_letter = input("Guess a letter of the word: ").lower()
15+
for position in range(len(chosen_word)):
16+
letter = chosen_word[position]
17+
if letter == guess_letter:
18+
display[position] = guess_letter
19+
print(display)
20+
21+
if guess_letter not in chosen_word:
22+
lives -= 1
23+
if lives == 0:
24+
game_over = True
25+
print("you lose!!")
26+
if '_' not in display:
27+
game_over = True
28+
print("you win!!")
29+
for char in chosen_word:
30+
word += char
31+
print(f"The word was: {word}")
32+
print(stages_file.stages[lives])
33+
34+
35+

HangnamGame/stages_file.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
stages = ['''
2+
+---+
3+
| |
4+
0 |
5+
||| |
6+
| | |
7+
|
8+
==========
9+
''', '''
10+
+---+
11+
| |
12+
0 |
13+
||| |
14+
| |
15+
|
16+
==========
17+
''', '''
18+
+---+
19+
| |
20+
0 |
21+
||| |
22+
|
23+
|
24+
==========
25+
''', '''
26+
+---+
27+
| |
28+
0 |
29+
|| |
30+
|
31+
|
32+
==========
33+
''', '''
34+
+---+
35+
| |
36+
0 |
37+
| |
38+
|
39+
|
40+
==========
41+
''', '''
42+
+---+
43+
| |
44+
0 |
45+
|
46+
|
47+
|
48+
==========
49+
''', '''
50+
+---+
51+
| |
52+
|
53+
|
54+
|
55+
|
56+
==========
57+
''']

0 commit comments

Comments
 (0)