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

  Рет қаралды 73,203

Jenny's Lectures CS IT

Jenny's Lectures CS IT

Күн бұрын

Пікірлер: 110
@lifebyvikk6751
@lifebyvikk6751 Жыл бұрын
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!
@BCKSPCEMusic
@BCKSPCEMusic Жыл бұрын
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
@ishanpandey9369
@ishanpandey9369 3 ай бұрын
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.
@Arceus948
@Arceus948 Жыл бұрын
Mam pls start machine learning Playlist, i beg u 😭😭🙏🏻🙏🏻🙏🏻
@santhoshk2722
@santhoshk2722 Жыл бұрын
I'm also waiting for that
@Cartoon123-x2b
@Cartoon123-x2b Жыл бұрын
Yes mam
@ShivamSingh-ez5dc
@ShivamSingh-ez5dc Жыл бұрын
Yes
@lifebyvikk6751
@lifebyvikk6751 Жыл бұрын
I think she has already done a superb job teaching python, I would probably master python well first if I were you
@Arceus948
@Arceus948 Жыл бұрын
@@lifebyvikk6751 i have already mastered python bro, now i want to learn ML
@subratkumarsahoo1946
@subratkumarsahoo1946 10 ай бұрын
waah didi waaah..waah didi waah...what an explanation?
@tmurari9452
@tmurari9452 Жыл бұрын
Mam please tell how to draw this Hangman pictures
@sachinwankhede3346
@sachinwankhede3346 9 ай бұрын
8:48 match expressions😊
@sciencetechy8058
@sciencetechy8058 2 ай бұрын
import random import list select=random.choice(list.char) lives=6 count=0 diplay=[] for i in range(len(select)): diplay +='_' #print(select) print(diplay) gameover=False while not gameover: guess=input("enter the word ").lower() for index in range(len(select)): letter=select[index] if letter== guess: diplay[index]=guess print(diplay) if guess not in select: lives -= 1 print(f"you left {lives} now") if lives == 0: gameover=True print("You Lose") if '_' not in diplay: gameover=True print("You Win") small change is if u get a Warning about lives is good for out put like 6,5,4,3,2,1,lose
@shivateja3123
@shivateja3123 Жыл бұрын
just subscribed and started watching
@munamarziya2546
@munamarziya2546 Жыл бұрын
Ma'am you better start your own college,,,,,,i am from non cs branch,,,,,you will get me and my friends as students for sure 🥺
@santhoshk2722
@santhoshk2722 Жыл бұрын
I'm also
@Harsha.108
@Harsha.108 4 ай бұрын
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'
@Lucky_truth
@Lucky_truth Жыл бұрын
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 word=random.choice(list1)#choose 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}")
@harshachaukyareddy1341
@harshachaukyareddy1341 Жыл бұрын
Excellent..💫
@vaibhavichanne6666
@vaibhavichanne6666 Жыл бұрын
guess=input("Guess a letter").lower()
@jjjmemes420
@jjjmemes420 6 ай бұрын
Super bro..... ❤❤
@ObulshettySrikari
@ObulshettySrikari Жыл бұрын
Mam instead of making an empty list can we write for i in chosen_list: print("_", end=" ") Will we get blanks mam??
@sushantprasai-m5w
@sushantprasai-m5w Жыл бұрын
display = ['_']*len(chosen_word) #This will do your job
@TSHILIDZI_MUNYAI
@TSHILIDZI_MUNYAI Жыл бұрын
How to u code the figure? The hangman stages that u just imported
@muneebbolo
@muneebbolo 10 ай бұрын
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 chosen_word=random.choice(words_file.words) 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!! ') print(hangman_stages.stages[lives]) ``` 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.
@-SakuraNoHana-
@-SakuraNoHana- 7 ай бұрын
Hello ma'am, Can you please make a video on python import time? I would really appreciate it. Thank you!
@ruhulameem1397
@ruhulameem1397 Жыл бұрын
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
@nikhils__2808
@nikhils__2808 2 ай бұрын
import random a = ['hand', 'cobra', 'elbow', 'dog', 'snake', 'copy', 'subway', 'key'] word = random.choice(a) # print(word) print(f'Number of letter in word = {len(word)}, {word}') list1 = [] for i in range(len(word)): list1 += '_' lives = 6 game_over = False while not game_over: guess_l = input("Enter word letter: ").lower() for i in word: if i == guess_l: letter = word.index(guess_l) list1[letter] = guess_l print(list1) if guess_l not in word: lives -= 1 if lives == 0: game_over = True print("You Lose!") if '_' not in list1: game_over = True print("You Win!!")
@georgevincent93
@georgevincent93 6 ай бұрын
import random fruits = ["apple", "banana", "orange", "grape", "kiwi", "strawberry", "watermelon", "pineapple", "blueberry", "mango", "pear", "peach", "plum", "cherry", "raspberry", "blackberry", "lemon", "lime", "coconut", "pomegranate", "apricot", "fig", "nectarine", "cranberry", "grapefruit", "tangerine", "lychee", "dragonfruit", "guava", "passionfruit", "melon", "persimmon", "kiwifruit", "cantaloupe", "honeydew", "date", "papaya", "jackfruit", "elderberry", "starfruit", "rhubarb", "boysenberry", "carambola", "kumquat", "soursop", "ackee", "breadfruit", "durian", "longan", "tamarind", "mulberry", "plantain", "quince", "soursop", "uglifruit"] guess=random.choice(fruits) length=len(guess) list1=[] for i in range(length): list1.append("-") print(list1) flag=0 n=0 while('-' in list1 and n!=6): x=input("guess the alphabet ") for i in range(length): if guess[i]==x: flag=1 list1[i]=x if(flag==1): print(list1) print("correct") if(flag==0): n+=1 print(list1) print("incorrect") print(f"you lose {n} life") flag=0 if '-' in list1: print(f"the correct answer was {guess}") print(" you lose the game") else: print(" you win the game")
@kirankumar-pv1yy
@kirankumar-pv1yy Жыл бұрын
Mam please Start Java Classes
@Khan_aamir.
@Khan_aamir. 8 ай бұрын
Thank you so much mam😊😊😊😊
@incomparablevikkie5507
@incomparablevikkie5507 Ай бұрын
How did you draw the images
@yogendrathakur8053
@yogendrathakur8053 Жыл бұрын
Very good 🎉😂
@mzxrex9381
@mzxrex9381 Жыл бұрын
Mam where should i run this code In jupyter notebook or vs code
@Praveen_C11
@Praveen_C11 6 ай бұрын
Vs is better
@glps369
@glps369 Жыл бұрын
Thank You So Much
@Rayray-cd3sz
@Rayray-cd3sz Жыл бұрын
# without figure and alternatives which are commented import random list_1 = ["apple", "banana", "cherry", "avocado", "kiwi", "jackfruit"] task_1 = random.choice(list_1) # list_2 = [] print("Guess name of the fruit ! ") #for dash in task_1: #list_2.append("_") # list_2 += "_" hidden_word = ["_"] * len(task_1) # print(hidden_word) is a list of strings print("".join(hidden_word)) # strings joined # print(hidden_word) remains a list of strings attempts = 0 no_of_guesses = 6 guessed_letter = set() while "_" in hidden_word and attempts < no_of_guesses: guess = input("Guess a letter of the word: ") if len(guess) != 1: print("Enter a single letter at a time! ") elif guess in guessed_letter: print("Already guessed, life reduced !") attempts += 1 print(f"{no_of_guesses - attempts} lives remaining") else: guessed_letter.add(guess) if guess in task_1: for i in range(len(task_1)): # for i, letter in enumerate(task_1): if task_1[i] == guess: # if letter == guess and hidden_word[i] == "_": hidden_word[i] = guess # print(hidden_word) print("".join(hidden_word)) else: attempts += 1 print(f"You have {no_of_guesses - attempts} guess left.") if "_" not in hidden_word: print("Congratulation, you have guessed the word") else: print(f"Your chances are over, the correct word is {task_1}")
@ngsscofficial
@ngsscofficial 5 ай бұрын
THANK YOU SO MUCH MAAM
@nityamittal6759
@nityamittal6759 Жыл бұрын
Mam can you make a playlist on asymptotic notation pls😃😃😃
@burragallaneeraj8136
@burragallaneeraj8136 Жыл бұрын
Please provide code in the description
@Shashank1703
@Shashank1703 Жыл бұрын
Mam Do one video on Java Programming Basics
@RishabhChatterjee-fg2gz
@RishabhChatterjee-fg2gz Жыл бұрын
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
@SaimaArif-n9w
@SaimaArif-n9w Жыл бұрын
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
@mahjabeen5806
@mahjabeen5806 2 ай бұрын
she did
@bestvideos9088
@bestvideos9088 10 ай бұрын
But how you make hangman_stages?
@omkarmurala2084
@omkarmurala2084 Жыл бұрын
Like u said we can make this hangman game in multiple ways can u please elaborate so that we can understand
@amitkmpbtup
@amitkmpbtup Жыл бұрын
IT DOESNT WORK WHEN U DO THE HANGMAN STGES IT IS SHOWING OUT OF INDEX WHEN I RUN IT PLS HELP
@akhil2721
@akhil2721 Жыл бұрын
Mam its a humble request please start c++, I have c++ in my 3 rd sem and currently i am in 2nd sem , so i will need it in 3rd sem .
@ChildhoodForever1808
@ChildhoodForever1808 Жыл бұрын
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 🙏
@rauhan_sheikh
@rauhan_sheikh Жыл бұрын
for the 1st 2-3 years focus on learning and building projects and also do internship in the 3rd year and based on that decide if you have to or want to do gate or not. if you decide you have better opportunities already because you have built good projects and have proof of work then leave it else if you still want to pursue gate then start. 1 and half year of dedicated preparation is good enough for gate.
@yogalakshmipabbisetty5966
@yogalakshmipabbisetty5966 Жыл бұрын
Mam could u plz start java
@bandikomalkumar8066
@bandikomalkumar8066 Жыл бұрын
What is meant by "Scratch file" which is displayed at top left corner of "Pycharm" application under pythonProject~New~Scratch File. Please 🥺 mam!
@Praveen_C11
@Praveen_C11 6 ай бұрын
Scratch file is just like any other file types like python file or html file or text file. Scratch is the most basic programming language one can learn, usually taught to kids in school. Pycharm has Scratch file as it's default file like how notepad has text file as default, u can change it to python by saving it with .py extension or as text file with .txt extension
@SriRam-in2zv
@SriRam-in2zv 8 ай бұрын
In Python 3.12, it is showing the hangman_stages function is not compatible. Please let me know if there is any other function which can be used in 3.12
@georgevincent93
@georgevincent93 6 ай бұрын
it is not an inbuild function it is another python file she created naming "hangman_stages"
@Taekookbelieverr
@Taekookbelieverr 4 ай бұрын
Can we add levels to this game like low level, medium level, hard level
@g.viswnathreddy1869
@g.viswnathreddy1869 Жыл бұрын
Mam ,provide notes in description please 😊😊
@kalyanitamanampudi
@kalyanitamanampudi 9 ай бұрын
Plzz mam start the classes of data science alsoo
@VenkateshAnnabathina
@VenkateshAnnabathina 5 ай бұрын
#need machine learning playlist
@MARUTHU_1801
@MARUTHU_1801 4 ай бұрын
where we can download the hangman stages Madam? is it available in the internet?
@avenger1898
@avenger1898 3 ай бұрын
#doing a hangaman game player1=list(input("ENTER A WORD:")) #print(player1) l=len(player1) word=list() for i in range(l): word.append('-') #print(word) print("YOU CAN GUESS ONLY \"6\" TIMES") count=0 guess="" while(count
@avenger1898
@avenger1898 3 ай бұрын
#doing a hangaman game player1=list(input("ENTER A WORD:")) #print(player1) l=len(player1) word=list() for i in range(l): word.append('-') #print(word) print("YOU CAN GUESS ONLY \"6\" TIMES") count=0 guess="" while(count
@jincejolly2791
@jincejolly2791 3 ай бұрын
import random word=["banana","orange","apple","carrot"] select=random.choice(word) selected=list(select) lenth=len(selected) underword=[] life=6 for i in range(lenth): underword.append("_") j=True while j==True: gues=input("Guess the letter: ") if gues in selected: d=selected.index(gues) underword[d]=gues selected.pop(d) selected.insert(d,"#") if(underword.count("_")==0): print("Congrats You won the game") j=False print(underword) break; else: j=True print(underword) print("Your remaining life is",life) else: if(life==0): print("You loose the game") j=False break; else: life-=1 j=True print(underword) print("Your remaining life",life)
@systembreaker4864
@systembreaker4864 Жыл бұрын
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
@braveheart3176RTY
@braveheart3176RTY 8 ай бұрын
hello im rhey from philippines
@marieswaran8124
@marieswaran8124 Жыл бұрын
Hi Madam, I have doubt in this session, How did you add display variable(list data type) with '_' string. Because those are different data type. Can you provide the answer for this doubt.
@rameshamma6497
@rameshamma6497 Жыл бұрын
The list contains an empty string, we are just concatenation with another string.
@lakshmivaddi4395
@lakshmivaddi4395 7 ай бұрын
hello mam,i have a doubt..suppose one word has two or three same letters like example swiss.if we guess a lettter s from word it should placed only one s.. right ?but in our program at a time three 3 S are placed in display..only one letter should be placed by one chance.please clarify my doubt mam
@hunterxcobby
@hunterxcobby 3 ай бұрын
no please it can display all the s in the chosen word
@-NChandana-pm9hb
@-NChandana-pm9hb Жыл бұрын
No module named hangman_stages
@abhileswar
@abhileswar Жыл бұрын
type error = showing cannot concatenate list (not "str") to list , in line display = display + '_' , mam can u explain this problem
@Chandu_SKY
@Chandu_SKY 11 ай бұрын
Hangman module not found error mam
@Bodigajohnygoud
@Bodigajohnygoud Жыл бұрын
mam what if a user enter's a correct word repeatedly??
@mattapallichandrashekar8947
@mattapallichandrashekar8947 Жыл бұрын
Mam please start Java play list
@Cartoon123-x2b
@Cartoon123-x2b Жыл бұрын
Mam uploaded more and more python videos please
@NARENDRAPAGOTI
@NARENDRAPAGOTI Жыл бұрын
mam please teach us java too
@avenger1898
@avenger1898 3 ай бұрын
mam but i am unable to print the STAGES
@abishakthd6884
@abishakthd6884 Жыл бұрын
I love you 😍 💗 mam
@vaibhavpatharkar6794
@vaibhavpatharkar6794 Жыл бұрын
Madam iff possible pl use hindi or mixed lang
@NikiNoName-cy6lo
@NikiNoName-cy6lo Ай бұрын
Guys I need to use IDLE. Like at school we need to put IDLE into python and then we get an empty file. Would her code also work on the system we use in school. I’m going to have an exam where we have to do this in python. Please help
@sonusonu-m5u
@sonusonu-m5u 2 ай бұрын
😊
@sharifullahsalarzai
@sharifullahsalarzai Жыл бұрын
Mam please complete c++ videos
@tech_gaming889
@tech_gaming889 Жыл бұрын
Mam we want emcet online classes
@everythingwithanirudha
@everythingwithanirudha Жыл бұрын
mam quality to improve karo, like camera or iphone, or may be the compression is bit high
@SarathReddyKakarla
@SarathReddyKakarla 3 ай бұрын
# hangman game 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 word=random.choice(list1)#choose 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}") WELCOME TO HANGMAN ['_', '_', '_'] Guess a lettert ['_', '_', 't'] Guess a letterr You have 5 heart left Guess a lettere You have 4 heart left Guess a lettere You have 3 heart left Guess a letterr You have 2 heart left Guess a letterr You have 1 heart left Guess a lettert ['_', '_', 't'] Guess a lettera ['_', 'a', 't'] Guess a letterh ['h', 'a', 't'] you won!
@shahiddar9852
@shahiddar9852 Жыл бұрын
Mam can you please send me the details how to make a website I want to make a website
@narendrakota890
@narendrakota890 Жыл бұрын
Third👍
@utkarsh_aa786
@utkarsh_aa786 Жыл бұрын
Maam I am just pass class 12th with( PCM) but ab Samajh nhi aa rha Iska kya 🤔kru?
@THEoneandonlystika
@THEoneandonlystika Жыл бұрын
here for beauty
@gangabankala7745
@gangabankala7745 Жыл бұрын
Madam please make sure send notes in description madam please it's my humble request 😢😢😢
@lovekushrajput442
@lovekushrajput442 Жыл бұрын
Third😄😄😄😂
@Viki.A1
@Viki.A1 Жыл бұрын
💞👍👍👍
@kirugaming6603
@kirugaming6603 Жыл бұрын
Mam vs code me karo code ko .......
@abishakthd6884
@abishakthd6884 Жыл бұрын
Mam u r so very beautiful
@Mesomeone7298
@Mesomeone7298 Жыл бұрын
thanks mam if you can please send us your source code Thank you
@nithinvasamsetti
@nithinvasamsetti 6 ай бұрын
🥵🥵🥵
@atmasgamingyt3168
@atmasgamingyt3168 Жыл бұрын
Second
@RouMuanNgaihte
@RouMuanNgaihte Жыл бұрын
First
@shivaojha6760
@shivaojha6760 Жыл бұрын
Mam I am a student of MITS Gwalior please help me python language
@Arceus948
@Arceus948 Жыл бұрын
Python language is non living thing bruh, how it can help u 😢😢😭😭
@maradanavivek2386
@maradanavivek2386 Жыл бұрын
​@@Arceus948😂😂😂😂
@wownoob-hp9pp
@wownoob-hp9pp Жыл бұрын
come to pakistan.
@adhitya001
@adhitya001 Жыл бұрын
Zero
@ravana194
@ravana194 Жыл бұрын
Mam will you marry me 😊😊
@coding_with_bf
@coding_with_bf Жыл бұрын
Mam 😢
@shaniskshanigamer4085
@shaniskshanigamer4085 Жыл бұрын
Hlo mam
Functions in Python | Introduction | Python for beginners #lec56
24:07
Jenny's Lectures CS IT
Рет қаралды 157 М.
Hangman Game for beginners |Introduction | Python Project for beginners #lec53
8:04
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
Let's code a HANGMAN GAME in Python! 🕺
25:07
Bro Code
Рет қаралды 21 М.
For Loop in Python | Python Tutorials for Beginners #lec42
19:42
Jenny's Lectures CS IT
Рет қаралды 180 М.
How To Code Hangman In Python | Tutorial For Beginners
16:26
Shaun Halverson
Рет қаралды 51 М.
Python Project 2 | Password Generator in Python | Python for Beginners #lec49
22:20
local and Global Scope in Python | Python Tutorials for Beginners #lec78
14:34
Jenny's Lectures CS IT
Рет қаралды 49 М.