Coders Packet

Hangman Game using Python

By N.Sruthi Goud

We have created a Hangman game with the help of Python language.It is a guessing game.

DESCRIPTION:

"words"; A collection of words used in the game.
"word"; A word randomly selected from the list of "words".
"bucket"; A container to store all the letters that have been guessed.
"build_word"; A container to hold the correctly guessed letters from the secret word.
"wrong_count"; A container to keep track of incorrectly guessed letters.
"games_won" and "games_lost"; Variables to keep a record of the total number of games won and lost respectively.
The function "margin(num)" is responsible, for printing margins ensuring formatting in the output.
The function "score()" displays the score by showing both games won and lost.
The function "letters()" shows both guessed and total letters during gameplay.
Lastly the function "start_game(word)" initializes each game setting up a word and preparing any necessary lists.

The main function `user_input()` handles user input during the game.
The function `good_letter(a)` checks if a letter is valid and hasn't been guessed already.
`letter_test(b)` verifies if the letter is present, in the mystery word.
`find_location(string letter)` finds all occurrences of a letter in the word.
`add_letter(letter, location_list)` correctly places a letter in the corresponding positions in the `build_word` list.
`word_test(compare)` compares the state of the `build_word` list with the mystery word.
The function `winner(ani_count)` displays an animation to celebrate winning.
Helper function `congratulations()` is responsible for showing congratulations text.
Function `wrong_letter(d)` handles incorrect letter guesses appropriately.
The function `loser(ani_count)` presents an animation when losing occurs.
Helper function `sorry()` displays game, over text as needed.
The function `hangman(count)` shows the state of hangman based on guesses made so far.
After winning or losing, it shows how many games won and lost.

https://coderspacket.com/uploads/user_files/2023-10/hangman-1697467433-2278.jpg

https://coderspacket.com/uploads/user_files/2023-10/hangman2-1697467644-2278.jpg

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by N.Sruthi Goud (Sruthi25)

Download packets of source code on Coders Packet