How To Code Hangman In Python | Tutorial For Beginners
ฝัง
- เผยแพร่เมื่อ 21 ก.ค. 2024
- Hey everyone!
In today's video we discuss how to code a classic childhood game with the help of python. This is a console app that allows users to guess a word and will update a stick figure drawing as time goes on. Everyone knows how hangman works, but does everyone know how to code it?
Watch to find out! :)
This project is available on GitHub at
--------------------------------------------------------------------------------------
github.com/ShaunHalverson/Pyt...
Add Me On Discord!
--------------------------------------------------------------------------------------
Username: Shaun(Hashtag)5626
Software Engineering / Programming for beginners / variables types / computer science /compsci / coding for beginners / learn how to program / learn how to code / python variables / python for beginners / coding tutorial / programming tutorial
Thanks for watching! :)
Want to see more? Click on this spicy link :D
/ @shaunhalverson
Assets in the thumbnail were provided by artists on
www.canva.com
All art and copyright ownership belongs to the artists on Canva and is under the protection of the Canva pro membership.
#programming #tutorial #learntocode
maan this guy is soo underrated, he only has 1,55k subscribers and 3,3k views. he explained how to create hangman in 15 minutes and it was very understandable, if you listen and look carefully in the vid you will understand and write it without any mistakes and errors. keep up the good work
Shaun I love it. You get right to the point without trying to be some over the top personality or data dumping a lot of useless words. Great work. Efficient
Shaun, your vids = the best.
keep on going.
bro, this was the best hangman video i have ever seen. this was exactly what i needed. keep up your work man!
hey, i love the way how you made the game. but how do you have to code it when you find a letter in the middle of a word because i can only find the first letter and the second and so up. can you help me?
nice and very helpful!
When i tried to run it, it ran how its supposed to, but wouldnt put the hangman signs when i get one wrong. and if i guess the word it does not say "game over thanks for playing". any help?
Hey man. I love your videos. I did everything in this video but when you try to play hangman it asks me to guess a letter over and over again. I do not know what’s going on. I did exactly what you did. Do you know what’s happening?
it just spams my console with "letters guessed so far: "
I love you bro
This is awesome 👍
Please make more video
Please make a video for snake 😩😩.
By the way your video's are so simple to understand. Thanks for making my coding journey so fun 😩😍
How come when i guess the right letters it still adds body parts to the hangman
didnt work. "just keeps saying letters guessed so far:"
hi I'm a beginner and had a doubt
in the function print word, line 63 iits written print(randomword[counter])
i didn't get why we wrote counter as counter is a variable
if someone could please help me out
cool video ! Literally save my python class > thanks
That’s awesome!
Thanks for watching :)
Did nobody realize that if you guess the letters out of order then you you lose one of your guesses even though that is right? that isnt how hangman works
There are some questions i have. Like why do you need counter variable in printword() function? It doesn't do any job in this "for" cycle and you didn't returned it.
Do you know if will it stills works if we remove the counter variable, increment and the [counter]?
you just saved my AP TEST SCORES THANK YOU
Source code by any chance??
Hey i have a problem. It all seems to be going well until i actually get a letter right. the program thinks that i got wrong and adds a body part onto hangman, but still adds the letter into the word. I even tried copy and pasting your code from github and it still wouldnt work. I used a different compiler too. Why is this happening?
edit: its because the use of current_guess_index is buggy, like another commenter said. It only works if you guess the first letter in the word. pretty big bug for a simple piece of code (relatively simple).
How do we newbies fix it?
Have you already fixed?
I fixed it.
Remove the current_guess_index variable entirely and change the line that uses it
"if(randomWord[current_guess_index] == letterGuessed):"
to: "if letterGuessed in randomWord:".
This will stop the program from caring which index in the randomWord youre dealing with and will simply check if letterGuessed is present in the word at all.
@@HaroldLavalley Thank you!! Never would have figured that out
@@HaroldLavalley yeah seems like the position of the letter in the word doesnt matter, nice find
How did you create all this logic? Coming up with all these variable names? I'd like to see how you break up the problem, your pseudocode before you code, unless you code as you go
I normally code it ahead of time and then read off of it during the recording! Also, I try to use variable names that are fairly specific that way you don’t have to backtrack later and find out what it’s for
Great question!
The current_guess_index +=1 case is kinda buggy..... If user guessed a letter from the back/end of a random.word the hangman is wrote incorrectly though.... It only works correctly if we guess a letter +1 from the start
Have you found a way to fix this?
@@jezzerthesnezzer2476 I gave up on learnig this bruh :(
@@arturwyscioek899 Alright that’s fine just trying to figure this out for a school project.
@@jezzerthesnezzer2476 I am currently doing the same. Did you find a fix?
I fixed it.
Remove the current_guess_index variable entirely and change the line that uses it
"if(randomWord[current_guess_index] == letterGuessed):"
to: "if letterGuessed in randomWord:".
This will stop the program from caring which index in the randomWord youre dealing with and will simply check if letterGuessed is present in the word at all
Love your videos.. Hope u can help me modify my python project.. I did what i think is right but when i run it. Error everywhere....
ikr
Say there is 6 letters already guessed. Any letter I guess after that always adds on a part of the hangman, even if the guess is right
Hmmm, can you compare your code with the stuff on Github? Or add me on Discord and I can try and assist.
@@ShaunHalverson sorry if I’m late. I have the same problem. Have you found a fix yet? Thanks
See my message above
@@r-ty_dragon1334 I'm trying to fix this problem too. No luck yet.
I’m a nerd😂😂😂😂😂😂😢😢😢😢😢
bro stop with the ads