Skip to content

Commit

Permalink
Merge pull request #94 from YashikaGupta03/master
Browse files Browse the repository at this point in the history
Created Hangman.py
  • Loading branch information
RK1905101 authored Oct 30, 2022
2 parents 1858f3e + 54f0f1f commit 2095de2
Showing 1 changed file with 127 additions and 0 deletions.
127 changes: 127 additions & 0 deletions Hangman.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import random

word_list = ['abruptly','absurd','abyss','affix','askew','avenue','awkward','axiom','azure','bagpipes','bandwagon','banjo',
'bayou','beekeeper','bikini','blitz','blizzard','boggle','bookworm','boxcar','boxful','buckaroo','buffalo','buffoon',
'buxom','buzzard','buzzing','buzzwords','caliph','cobweb','cockiness','croquet','crypt','curacao','cycle','daiquiri',
'dirndl','disavow','dizzying','duplex','dwarves','embezzle','equip','espionage','euouae','exodus','faking','fishhook',
'fixable','fjord','flapjack','flopping','fluffiness','flyby','foxglove','frazzled','frizzled','fuchsia','funny', 'gabby',
'galaxy','galvanize','gazebo','giaour','gizmo','glowworm','glyph','gnarly','gnostic','gossip','grogginess','haiku',
'haphazard','hyphen','iatrogenic','icebox','injury','ivory','ivy','jackpot','jaundice','jawbreaker','jaywalk','jazziest',
'jazzy','jelly','jigsaw','jinx','jiujitsu','jockey','jogging','joking','jovial','joyful','juicy','jukebox',
'jumbo','kayak','kazoo','keyhole','khaki','kilobyte','kiosk','kitsch','kiwifruit','klutz','knapsack','larynx',
'lengths','lucky','luxury','lymph','marquis','matrix','megahertz','microwave','mnemonic','mystify','naphtha','nightclub',
'nowadays','numbskull','nymph','onyx','ovary','oxidize','oxygen','pajama','peekaboo','phlegm','pixel','pizazz',
'pneumonia','polka','pshaw','psyche','puppy','puzzling','quartz','queue','quips','quixotic','quiz','quizzes',
'quorum','razzmatazz','rhubarb','rhythm','rickshaw','schnapps','scratch','shiv','snazzy','sphinx','spritz','squawk',
'staff','strength','strengths','stretch','stronghold','stymied','subway','swivel','syndrome','thriftless','thumbscrew','topaz',
'transcript','transgress','transplant','triphthong','twelfth','twelfths','unknown','unworthy','unzip','uptown','vaporize','vixen',
'vodka','voodoo','vortex','voyeurism','walkway','waltz','wave','wavy','waxy','wellspring','wheezy','whiskey',
'whizzing','whomever','wimpy','witchcraft','wizard','woozy','wristwatch','wyvern','xylophone','yachtsman','yippee','yoked',
'youthful','yummy','zephyr','zigzag','zigzagging','zilch','zipper','zodiac','zombie', ]


logo = '''
_
| |
| |__ __ _ _ __ __ _ _ __ ___ __ _ _ __
| '_ \ / _` | '_ \ / _` | '_ ` _ \ / _` | '_ \
| | | | (_| | | | | (_| | | | | | | (_| | | | |
|_| |_|\__,_|_| |_|\__, |_| |_| |_|\__,_|_| |_|
__/ |
|___/ '''


stages = ['''
+---+
| |
O |
/|\ |
/ \ |
|
=========
''', '''
+---+
| |
O |
/|\ |
/ |
|
=========
''', '''
+---+
| |
O |
/|\ |
|
|
=========
''', '''
+---+
| |
O |
/| |
|
|
=========''', '''
+---+
| |
O |
| |
|
|
=========
''', '''
+---+
| |
O |
|
|
|
=========
''', '''
+---+
| |
|
|
|
|
=========
''']

print(logo)
game_is_finished = False
lives = len(stages) - 1

chosen_word = random.choice(word_list)
word_length = len(chosen_word)
display=[]

for i in range(0,word_length) :
display+="_"

while not game_is_finished :
guess = input("Guess a letter: ").lower()
if guess in display:
print(f"You've already guessed {guess}")

elif not "_" in display:
game_is_finished = True
print("You win.")

elif guess not in chosen_word :
print(f"You guessed {guess}, that's not in the word. You lose a life.")
lives -= 1
if lives == 0:
game_is_finished = True
print("You lose.")
print(f"Word is : {chosen_word}")

else :
for position in range(0,word_length) :
letter=chosen_word[position]
if letter == guess:
display[position] = letter
print(display)

print(stages[lives])

0 comments on commit 2095de2

Please sign in to comment.