Skip to content

Commit 2458575

Browse files
committed
Hangman Project
1 parent 1701d8a commit 2458575

File tree

3 files changed

+144
-0
lines changed

3 files changed

+144
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

hangman.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from random import choice
2+
3+
4+
def select_word():
5+
with open("words.txt", mode='r') as words:
6+
reading_lines = words.readlines()
7+
return choice(reading_lines).strip()
8+
9+
10+
selected_word = list(select_word().lower())
11+
word_length = len(selected_word)
12+
13+
player1_guess = ["-"] * word_length
14+
15+
print(" ".join(player1_guess))
16+
print(selected_word)
17+
18+
19+
# Get the user player one input
20+
counter = 6
21+
while (counter > 0):
22+
listening = input("Enter your input \n")
23+
one_exist = 0
24+
for index, char in enumerate(selected_word):
25+
if (listening == char):
26+
player1_guess[index] = char
27+
print(" ".join(player1_guess))
28+
one_exist += 1
29+
if (one_exist < 1):
30+
counter -= 1
31+
print(
32+
f"That is incorrect. You have {counter} lives left. Please try again!\n")
33+
print(" ".join(player1_guess))
34+
35+
print("You lose!")
36+
37+
38+
# create an array that will store all the correct values first starting out with ----- lines after replacing each with the correct value.
39+
# Using the length of the selected String.
40+
41+
42+
# create a counter for 6 tries if you get more you lose
43+
# if you guess all the letters you win
44+
# each turn will check this logic

words.txt

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
Umbrella
2+
Quasar
3+
Harmony
4+
Spectrum
5+
Intricate
6+
Ponder
7+
Luminous
8+
Quixotic
9+
Velocity
10+
Whimsical
11+
Resilient
12+
Enigma
13+
Nebula
14+
Serendipity
15+
Catalyst
16+
Tranquil
17+
Nexus
18+
Zephyr
19+
Quench
20+
Mosaic
21+
Resonance
22+
Illuminate
23+
Quantum
24+
Ethereal
25+
Vibrant
26+
Epiphany
27+
Cascade
28+
Jubilant
29+
Quagmire
30+
Cacophony
31+
Verbose
32+
Ineffable
33+
Mellifluous
34+
Synchronize
35+
Enigmatic
36+
Halcyon
37+
Utopia
38+
Inquisitive
39+
Serenity
40+
Pinnacle
41+
Effervescent
42+
Kaleidoscope
43+
Labyrinth
44+
Aplomb
45+
Ephemeral
46+
Zenith
47+
Mellifluous
48+
Panorama
49+
Eloquent
50+
Quizzical
51+
Renaissance
52+
Ebullient
53+
Nebulous
54+
Obfuscate
55+
Mellifluous
56+
Bucolic
57+
Epitome
58+
Nocturnal
59+
Odyssey
60+
Quotidian
61+
Tenacious
62+
Ennui
63+
Solitude
64+
Rendezvous
65+
Mellifluous
66+
Piquant
67+
Ineffable
68+
Ephemeral
69+
Inscrutable
70+
Enigmatic
71+
Mellifluous
72+
Incandescent
73+
Jubilant
74+
Disparate
75+
Mellifluous
76+
Quotient
77+
Luminosity
78+
Xenon
79+
Mellifluous
80+
Quiescent
81+
Unanimous
82+
Languid
83+
Mellifluous
84+
Resplendent
85+
Zestful
86+
Mellifluous
87+
Resolute
88+
Mellifluous
89+
Mellifluous
90+
Cynosure
91+
Oblique
92+
Mellifluous
93+
Mellifluous
94+
Trepidation
95+
Mellifluous
96+
Mellifluous
97+
Quandary
98+
Paradox
99+
Mellifluous
100+
Ineffable

0 commit comments

Comments
 (0)