Hangman Game in Python | Python Project #3 | Python Project for beginners #lec55

preview_player
Показать описание
In this Python Lecture we are going to build Hangman Game . We will discuss the Complete Code line-by-line. The game will allow for user input, and will also output a visual of the hangman alongside the word that’s being guessed.

*********************************************

Connect & Contact Me:

*******************************************

More Playlists:

#pythonprojects #pythonforbeginners #python #jennyslectures #pythonprogramming #hangman
Рекомендации по теме
Комментарии
Автор

I just like how you break complex problems into small problems in order to have them solved, , the way you pause and think and write code is very helpful for someone who wants to really learn how to solve programming problems not only in python but any language for that matter! Thank you Jenny!

lifebyvikk
Автор

Mam pls start machine learning Playlist, i beg u 😭😭🙏🏻🙏🏻🙏🏻

Arceus
Автор

Well this was really crazy in a good way, i don't know if this channel is for explaining kids but i am 24years old & enjoying it

BCKSPCEMusic
Автор

00:04 Creating a Hangman game in Python
02:32 Generating and displaying a random word in Hangman game
07:50 Comparison of guessed letters with chosen word
10:30 Using a while loop for the Hangman game
15:55 Handling user input for Hangman game in Python.
18:13 Decrease life count by 1 for every wrong guess
23:03 Troubleshooting and correction of code errors
25:23 Understanding the stages and lives in Hangman game
30:01 Modify the Hangman project according to your preferences
Crafted by Merlin AI.

ishanpandey
Автор

Mam please tell how to draw this Hangman pictures

tmurari
Автор

Ma'am you better start your own am from non cs will get me and my friends as students for sure 🥺

munamarziya
Автор

Hello ma'am,
Can you please make a video on python import time?
I would really appreciate it.
Thank you!

-SakuraNoHana-
Автор

Mam instead of making an empty list can we write
for i in chosen_list:
print("_", end=" ")
Will we get blanks mam??

ObulshettySrikari
Автор

In the program of hangman game you have not defined lives. Your program is not showing name error for lives but mine is showing name error. please clear it mam

SaimaArif-nw
Автор

Hello mam

mam please make video on numpy, matplotlib, and pandas library of python because i am preparing as a data analytics and these library is necessary for being data analytics ur concept and way of teaching is very elegant and fabulous i learn data structures from your tutorial and suggest my junior to watch your video of DSA please mam make video on these library tl

thank you

ruhulameem
Автор

IT DOESNT WORK WHEN U DO THE HANGMAN STGES IT IS SHOWING OUT OF INDEX WHEN I RUN IT PLS HELP

amitkmpbtup
Автор

Ma'am I am currently in 1st year of btech and I want to prepare for gate. When do you think I should start preparing for it please tell me 🙏

ChildhoodForever
Автор

for example, the choosed word is "krishna"
suppose we typed 'a', guess is correct, 'a' is present in 'krishna' and a is filled in blank list, no lives lost
but if we type 'a' again, next time... same happens, , but we should lose one life, , because one 'a' present in 'krishna' is already filled.. there is no another 'a'

Harsha.
Автор

How to u code the figure? The hangman stages that u just imported

TSHILIDZI_MUNYAI
Автор

Mam can you make a playlist on asymptotic notation pls😃😃😃

nityamittal
Автор

Ma'am I'm currently studying in 1st year of diploma in computer science and technology and my dream is to give gate exam and python is my favorite language and I don't want to do any job, I want to be a data scientist professional and want to research about data science field like machine learning, deep learning, artificial intelligence, etc..
I have a question
what is big data?

and I want to say you to make this course as a professional python developer

RishabhChatterjee-fggz
Автор

Can we add levels to this game like low level, medium level, hard level

Taekookbelieverr
Автор

Mam this has one problem that is if we enter correct letter again in the input it will not take lives it's like we can run this continuously until the whole list of "_" these characters is replaced with letters

systembreaker
Автор

Here's what each part of the code does:

1. **Imports and Initial Setup**

import random
import hangman_stages
import words_file
```
These lines import the necessary modules for the game. `random` is a built-in Python module for generating random numbers. `hangman_stages` and `words_file` are custom modules that contain the hangman stages and the word list, respectively.

2. **Game Variables**

lives=6

print(chosen_word)
```
Here, the variable `lives` is set to 6, representing the number of incorrect guesses the player is allowed. `chosen_word` is a randomly selected word from the word list in `words_file`. This word is what the player has to guess.

3. **Display Setup**

display=[]
for i in range(len(chosen_word)): #0 1 2 3 4
display +='_'
print(display)
```
This code creates a list `display` that is used to show the player's progress in guessing the word. It starts as a list of underscores, with one underscore for each letter in `chosen_word`.

4. **Game Loop**

while not game_over:
letter_guess = input('Guess the letter ').lower() # r
for position in range(len(chosen_word)):
letter=chosen_word[position]
if letter==letter_guess:
display[position] = letter_guess
print(display)
```
This is the main game loop. The player is asked to guess a letter, which is then checked against each letter in `chosen_word`. If the guessed letter is in the word, the corresponding underscore in `display` is replaced with the letter.

5. **Lives and Game Over Conditions**

if letter_guess not in chosen_word:
lives -= 1
if lives == 0:
game_over = True
print('Game Over, You Lose! ')
if '_' not in display:
game_over = True
print('You win!! ')

```
If the guessed letter is not in the word, the player loses a life. If all lives are lost (`lives == 0`), the game ends and the player loses. If there are no more underscores in `display`, meaning the player has guessed all the letters, the game also ends and the player wins. After each guess, the current hangman stage is printed based on the number of remaining lives.

muneebbolo
Автор

import random
print("WELCOME TO HANGMAN")
heart=6
won=False
list1= ["lamp", "chair", "book", "spoon", "tree", "hat", "bike", "door", "pen", "cup", "shoe", "clock", "ball", "table", "sun", "moon", "flower", "bridge", "cloud", "pillow"]
# random words
a random word from the list
word=list(word)#make it in to list again
output = ["_"] * len(word)
print(output)
while heart:
guess=input("Guess a letter")
for i in range(len(word)):
if(guess==word[i]):
output[i]=guess
print(output)
if(output==word):
won=True
print("you won!")

if (guess not in word):
heart -= 1
print(f"You have {heart} heart left")
if(won==True):
break
if(heart==0):
print(f"The word is {word}")

Lucky_truth