How to build HANGMAN with Python in 10 MINUTES

  Рет қаралды 471,377

Kite

Kite

Күн бұрын

Пікірлер: 479
@victoriatomokocountryman6129
@victoriatomokocountryman6129 4 жыл бұрын
I don't think I've ever clicked to watch an ad in my entire life until now; totally worth it.
@unbreakable7643
@unbreakable7643 4 жыл бұрын
same
@unbreakable7643
@unbreakable7643 4 жыл бұрын
whaattttttttttttttttttttttttttttttttttttttttttttttttttttt this is a add
@100percentzak
@100percentzak 4 жыл бұрын
Same
@ComputerScienceTechworld
@ComputerScienceTechworld 3 жыл бұрын
Whf! what do you mean? Every video has twice ad, so whats the problem
@snowy8926
@snowy8926 4 жыл бұрын
I guess I'm the only person here who actually searched for this video lol
@zygarlio9885
@zygarlio9885 4 жыл бұрын
Me too
@tochimclaren
@tochimclaren 4 жыл бұрын
We are in this together.
@vlogginggabes3864
@vlogginggabes3864 4 жыл бұрын
same
@ashsureshkumar9150
@ashsureshkumar9150 4 жыл бұрын
Me too
@kimilao5235
@kimilao5235 4 жыл бұрын
Me too.
@DragonRazor9283
@DragonRazor9283 4 жыл бұрын
I was stuck for hours and hours trying to figure out how to replace those underscores with the user’s guess under multiple occurrences. This video saved my life.
@KiteHQ
@KiteHQ 4 жыл бұрын
So glad to we could save you, Vaiterius! Thanks for the love.
@littlesheep8644
@littlesheep8644 4 жыл бұрын
I'm having the same problem, what did you do?
@braddaily8688
@braddaily8688 4 жыл бұрын
@@littlesheep8644 2 months late, but, if you're still stuck on this, he 1: split up the individual letters of word into a separate list word_as_list using list(word) 2: used the enumerate function, which returns the index value and letter for each character of a string, as a list of tuples ex: ( for a word 'hey', [(0, 'h'), (1, 'e'), (2, 'y')] ) (he essentially dissected the word into individual letters, each stored in a list alongside their index value as a tuple (index_value, letter) ) 3: iterated over the list of tuples, for each tuple using *i* for the index value and *letter* for the letter 4: appended only the index values of the guessed letters to another list, called indices 5: iterated over the indices he collected, and used the index value to jump to the position in word_as_list where the corresponding letter was guessed, and replaced the underscore in word_as_list with the guessed letter (word_as_list would look like ['_', '_', '_'] before, and look like ['_', 'e', '_'] afterwards if 'e' was hypothetically the guessed letter) 6: he used ' '.join to convert the list format of word_as_list into a string and assign the new string as word_completion (remember word_as_list was just word_completed, but chopped up) Don't know if you've figured it out already, but hope this helps!
@sarahharrison5798
@sarahharrison5798 3 жыл бұрын
Me but i made mine before seeing this
@aydenshahraki1084
@aydenshahraki1084 3 жыл бұрын
Same. But I'm still not quite sure how kite did it. He's appending i to the list if the corresponding...
@wqltr1822
@wqltr1822 3 жыл бұрын
As a absolute beginner to programming, I made my coded a game of hangman myself to then compare it to a more optimized version. These are the three lessons I've learned: 1. A lot of the time python has some QOL functions that save you 10 lines of code. 2. Prepare individual functions and then have code which runs a combinations of functions, which gives you a much more understandable and cleaner program. 3. This one ties into the first, really think about what you are doing and what you're planning to. This video was very good btw!
@KiteHQ
@KiteHQ 4 жыл бұрын
If you've scrolled down to the comments, let's play our own game of hangman... _ _ T _ _ _ _ P _ _ _ _
@erictrautmiller1154
@erictrautmiller1154 4 жыл бұрын
e
@KiteHQ
@KiteHQ 4 жыл бұрын
_ _ T _ _ _ _ P _ E _ E
@skandersoltane2001
@skandersoltane2001 4 жыл бұрын
A
@KiteHQ
@KiteHQ 4 жыл бұрын
A _ T _ _ _ _ P _ E _ E
@devayanbhattacharjee2326
@devayanbhattacharjee2326 4 жыл бұрын
AUTOCOMPLETE
@bruinsmash8836
@bruinsmash8836 4 жыл бұрын
Cool video, a bit fast for a beginner, but overall very helpful.
@noobnub7305
@noobnub7305 3 жыл бұрын
for beginners, LMAO
@zestastic3359
@zestastic3359 3 жыл бұрын
@@noobnub7305 Creating hangman is a beginner coding project.
@friday8118
@friday8118 2 жыл бұрын
I was gonna say the same thing.
@writershard5065
@writershard5065 Жыл бұрын
@@noobnub7305 Always gotta have egotistical programmers in these comment sections lol.
@ianpimenta9197
@ianpimenta9197 4 жыл бұрын
I just started learning how to code and this video has been super helpful. My first code was a madlibs game, but I wanted to try a game that was more responsive to user input: hang man! This video is so great because it provides a solid base for the viewer to expand on. Im going to try to add 3 different difficulty levels that the user can select which will adjust the amount of guesses per word. Im sure a more experienced programmer could add a gui. Awesome vid!
@TatesWorldGlobal
@TatesWorldGlobal 4 жыл бұрын
print("relatable") xD
@pizzamccheese9278
@pizzamccheese9278 4 жыл бұрын
how do you draw the hangman's gallow thingy i.e. the stick on the left side and his body
@ihebbenali2745
@ihebbenali2745 4 жыл бұрын
i made this game before watching this video and tried to compare the codes, your code is very simple,short and a bit advanced from mine but many similarlies. mine has a hint system and second player mode, where the 1st player enters a hint and word for the 2nd player to guess. in the hint sysetem you can chose to either show 1 letter if the word is less than 4 letters long, or 2 letter if the word is longer. or you can chose to get the type of the word such as verb,adj, animal...
@ihebbenali2745
@ihebbenali2745 2 жыл бұрын
@Gotta Go no realy i had very basic knowledge of python and basic sense for game dev. you just have to know a bit of both to be honest. mostly the logic of how games should be coded, but i didnt go too deep in that. and then i gave it a shot. also i cant beleive im replying in 10 min for a reply on my comment that's 1 year old😂😂. i realy have to find something to do with my life lmao
@natasdabsi1138
@natasdabsi1138 Жыл бұрын
@@ihebbenali2745 update?
@akankshayeola3472
@akankshayeola3472 3 жыл бұрын
what does 'i for i' mean here? Really trying to figure out the indices = [ i for i, letter in enumerate(rand_word) if letter==guess] part, any explanation will be helpful! Thanks
@jhintuoso8137
@jhintuoso8137 3 жыл бұрын
Its because of function enumirate()
@asdfasf
@asdfasf 3 жыл бұрын
brilliant video - thanks. My kids are learning at school and this will be very good to push their thinking.
@Emmi_casei
@Emmi_casei Жыл бұрын
This was 10 mins for you. We made it in 1 hour after thinking about what you have done and why it has done and all. But afterall this whole video was so helpful...☺️, so thanks buddy...
@gyeumkim4536
@gyeumkim4536 4 жыл бұрын
I got error; Unable to import 'words' pylint(import-error) [2, 1] how to solve it?
@mohammadamintorabi8415
@mohammadamintorabi8415 2 жыл бұрын
Can someone explain line 32 (or expand it): indicies= [i for i, letter in enumerate(word) if letter == guess]. I don't understand first "i" (i for ....)? Is for loop nested in If statement or the other way?
@Spongebob_Squarepants
@Spongebob_Squarepants 4 жыл бұрын
i didn't feel like using completed code or typing the stages of the hangman, so i turned it into Russian hangman where every time the player gets a letter wrong, a bullet will be added in the chamber. So each time they miss a letter, the probability of them losing gets higher.
@GabrielsEpicLifeofGoals
@GabrielsEpicLifeofGoals 3 жыл бұрын
Cool!
@fumiya9078
@fumiya9078 Жыл бұрын
This is lightspeed compared to the other tutorials I watched and I love it
@henningreichenbach4945
@henningreichenbach4945 4 жыл бұрын
Very good video and extremly helpful for New programmers like me who just need an example to copy. Can you guys please make more mini project videos like this. There are really not a lot of coding examples for python on youtube
@KiteHQ
@KiteHQ 4 жыл бұрын
Check out our Python Projects playlist and Beginner Tutorials playlist for more! Glad you enjoyed the video. kzbin.info/www/bejne/m6W2g6GGpZ57btU
@neodong6060
@neodong6060 2 жыл бұрын
caaaaaaaaaaaaaaap. more python tutorials than there are js i believe
@weeson
@weeson 2 жыл бұрын
at 3:03 why is the while loop not guessed? Cant it be while guessd != True ?
@weeson
@weeson 2 жыл бұрын
im just unsure what the not guessed is doing
@weeson
@weeson 2 жыл бұрын
wouldnt not guessed evaluate to true
@benedikt7846
@benedikt7846 4 жыл бұрын
How can you make it print space " " in between the underscores shown for the word, for instance I copied the code given and it prints "________" instead of " _ _ _ _ _ _ " which is kind of hard to read so you can count the letters. Anybody got pointers?
@mayedalshamsi
@mayedalshamsi 2 жыл бұрын
In line 10 where you set an underscore for each letter, add a space after the underscore, inside the quotation marks. "_ " instead of "_".
@stephaniebeals5936
@stephaniebeals5936 4 жыл бұрын
how can you do word_as_list=list(word_completion) if word_completion is not introduced until later in the loop?
@jaysonkxm3058
@jaysonkxm3058 4 жыл бұрын
I tried to import the word list from your code using the exact same thing I cant.
@sylviasobol4815
@sylviasobol4815 3 жыл бұрын
What a great code! Thanks for posting, made my life so much easier when I compared it to my code )
@lat_06
@lat_06 3 жыл бұрын
hello but i have this error ImportError: cannot import name 'word_list' from 'words' can you help me thank you
@sienna.6654
@sienna.6654 3 жыл бұрын
I think it’s because he had a separate python file as that try this def get_word(): Word_list = [“put”, “your”, “words” , “here”] Word = random.choice(word_list) You will have part of this code already there Edit: hope this helps
@ahmetsenol6104
@ahmetsenol6104 Жыл бұрын
You are so fast that i dont even want to do it anymore :D It was like trying to catch a bus.
@nasajain
@nasajain 4 жыл бұрын
For some reason, in line 53, when I type if guessed: print("Congrats!") It is returning an error saying the the ":" is an invalid syntax. Can you please explain what to do to fix it?
@SachinNath-dj4lk
@SachinNath-dj4lk 4 жыл бұрын
Try typing if guessed == True:
@nicolatesla5607
@nicolatesla5607 4 жыл бұрын
Type True in place of guessed
@nasajain
@nasajain 4 жыл бұрын
Thanks guys! Will try these and get back
@robynsoar6574
@robynsoar6574 5 ай бұрын
@@nasajain Bro never got back
@nasajain7631
@nasajain7631 5 ай бұрын
@@robynsoar6574 Oops 💀 It prob worked tho
@myke6972
@myke6972 2 жыл бұрын
i dont get the indices part, maybe because im new, idk, can someone pls explain me.
@IvanMartinez-tn3yy
@IvanMartinez-tn3yy Жыл бұрын
What is the point of lines 135 and 136 @ 7:42
@jhonfrietzofqueria6893
@jhonfrietzofqueria6893 3 ай бұрын
Is it possible to add some sort of hint for the words at the top? For example: It is used for writing in whiteboard(marker)
@billychan9065
@billychan9065 4 жыл бұрын
"simple hangman game" [cry]
@ounsspace2573
@ounsspace2573 3 жыл бұрын
It's so hardddddddddddd(cryyyyyyyyyyyyyyyyyyyyyyyyyyyyyy)
@punyan775
@punyan775 2 жыл бұрын
5:09 indices = [i for i, letter in enumerate(word) if letter== guess] is a bit confusing
@emiliecote8248
@emiliecote8248 4 жыл бұрын
@ 5:12 I don’t understand what the i for i means when you’re defining indices
@siddhantprakash.
@siddhantprakash. 4 жыл бұрын
Refer list comprehension, you'll get that. syntax for list comprehension: [ for in if ] and in the video we are taking loop var as i , letter because enumerate produces Hope it helps :)
@janpoonthong
@janpoonthong 4 жыл бұрын
[i for i, letter in enumerate(word) if letter == guess] Means: indices = [] for i, letter in enumerate(word): if letter == guess: indices.append(i)
@alfredvonhofsten4010
@alfredvonhofsten4010 4 жыл бұрын
this man. types. pretty fast
@mimisholdingspvt.ltd.6091
@mimisholdingspvt.ltd.6091 4 жыл бұрын
Hi guys, novice here. could someone explain 4:58 where the code says 'i for i, letter' I know the second i is the index and letter is the corresponding letter, but what is the first i? thanks so much in advance
@jetspray3
@jetspray3 2 жыл бұрын
The enumerate function returns the index which is 'i' and the individual 'letter' which would be starting from the first character in the string. So 'i' would be the index that would be strip out and stored in a list only if the letter you guess is in the string. You can also strip out the 'letter' as well only if you have use for it. This statement is a shortcut which is called a list comprehension in python.
@bern1223
@bern1223 4 жыл бұрын
Amazing tutorial, thanks for the ad!
@jeff.gef123
@jeff.gef123 4 жыл бұрын
I have a problem, In line no. 53 I typed" If guessed" and an error is coming "unresolved reference 'guessed' "
@jeff.gef123
@jeff.gef123 4 жыл бұрын
plz help me
@Lizka011
@Lizka011 4 жыл бұрын
@@jeff.gef123 a bit late but i had same shit. i think it has to do with an indent, like move the function? python is about syntax so
@benjamintunaru7214
@benjamintunaru7214 4 жыл бұрын
I really like your videos! thank you !
@KiteHQ
@KiteHQ 4 жыл бұрын
Glad you enjoy them. Thank you!
@ryxnzippedem5144
@ryxnzippedem5144 4 жыл бұрын
Whats ur snap
@Rich171090
@Rich171090 3 жыл бұрын
Does this take into account words that have the same letter more than once? For example "Cheese"? It checks to see whether the guessed letter is in the hidden word but does it check to see if it appears more than once? Thank you
@samihatoum
@samihatoum 4 жыл бұрын
could anyone explain what he is doing at 5:00 using enumerate?
@parkuuu
@parkuuu 4 жыл бұрын
Enumerate returns both the Index number and the item. He's matching if the input matches any of the letters on the word, and then returning the index number to determine the position of the letter. He then converts the blanks into a list so that he could replace the blank with the correct letter itself (as a list by using the index), then converting it back to a string. Rinse and repeat the whole process.
@samihatoum
@samihatoum 4 жыл бұрын
Park Musni that helps a lot, thank you
@parkuuu
@parkuuu 4 жыл бұрын
@@samihatoum I am particularly new at programming, I'm glad I gave a clear explanation hahaha
@ntrlshorts958
@ntrlshorts958 3 жыл бұрын
nice tutorial, I tried your advice out for hangman python but for some reason there is a "invalid syntax error" and I did it step by step is their anyway you can look at it and help me fix it?
@timothyivanov9447
@timothyivanov9447 4 жыл бұрын
THIS DUDES WRITING IS GOD SPEED ALIN
@AllTypeGaming6596
@AllTypeGaming6596 4 жыл бұрын
I see your ad in my feed lots time but i didn't click it 😅 and finally i click today
@0_-
@0_- 4 жыл бұрын
This is the first video I saw of you!
@yuvrajwalia1797
@yuvrajwalia1797 4 жыл бұрын
Great video! I tried writing the code, and I found an error on Line 102. Instead of "return stages[tries]" it should be "return stages[tries-1] since its an array with only 6 elements. So it goes 0-1-2-3-4-5, and there's no stage 6.
@KiteHQ
@KiteHQ 4 жыл бұрын
Hi ɣʋⱴraʝ Walia, thanks for exploring the code and sharing thoughtful feedback! If the stages array had just six elements, you’d be correct in using tries-1 for the index, but this array actually has seven elements (initial display + 6 after each mistake), so using tries by itself is the appropriate index value.
@mayedalshamsi
@mayedalshamsi 2 жыл бұрын
Get rekt, Yuvraj!
@benjamintunaru7214
@benjamintunaru7214 4 жыл бұрын
What theme are you using for VS Code?
@KiteHQ
@KiteHQ 4 жыл бұрын
one monokai with some adjustments!
@benjamintunaru7214
@benjamintunaru7214 4 жыл бұрын
@@KiteHQ Ok TK
@ashishupadhya1545
@ashishupadhya1545 4 жыл бұрын
@@benjamintunaru7214उए
@atbuivan35
@atbuivan35 4 жыл бұрын
@@KiteHQ its seem like the package names word_list doesnt exit
@friday8118
@friday8118 2 жыл бұрын
This was quick af, I think I am gonna have to keep searching.
@deotheoverlord
@deotheoverlord 4 жыл бұрын
This is really cool, thank you man! instantly subscribed to your channel.
@Nobody-xp6ip
@Nobody-xp6ip 11 ай бұрын
I made a version of Hangman similar to this but without the visual hanging man. In mines, there is a hint system as well
@1979nige
@1979nige 4 жыл бұрын
awesome video, im using a .txt file for the game to choose a random word but when its counting the characters of the word its counting one at the end of the word even though there is no space or additional character?? anyone else had this issue?
@N00bGuitarist
@N00bGuitarist 3 жыл бұрын
I'm a beginner and i wrote the program on my own. Am i doing good?
@mohitbareja5059
@mohitbareja5059 3 жыл бұрын
Yupp Bro. I also wrote plenty of it by myself but here for reference to make it better.
@N00bGuitarist
@N00bGuitarist 3 жыл бұрын
@@mohitbareja5059 great bro! Happy coding ❤️😁
@caleb-fg1nl
@caleb-fg1nl 2 жыл бұрын
Can someone explain why triple " was used instead of the usual single " for the stages list
@HeadofSails
@HeadofSails Жыл бұрын
I think triple is when you want the output to be wrapped/chunks - formatting
@mafulynch
@mafulynch 4 жыл бұрын
Why when you dreaw the stages one arm is represented as \\ and one leg is \\? Great video, a bit fast to follow for begginers
@beetal3850
@beetal3850 4 жыл бұрын
in a string \ is a special character which lets you put a double quote in a double quote so you have to put 2
@mafulynch
@mafulynch 4 жыл бұрын
@@beetal3850 thanks for your reply!
@himanshujain7014
@himanshujain7014 4 жыл бұрын
Do you y to try too in yp
@aasshmangupta9553
@aasshmangupta9553 2 жыл бұрын
This Dude: Fast as a leopard but in writing Me: *Taking 10 years to write the whole code*
@heyman7891
@heyman7891 3 жыл бұрын
If you have a plain list of words how do you implent this ' and this , symbol on every word??
@arvindbabu2816
@arvindbabu2816 4 жыл бұрын
I am getting import error ImportError: cannot import name 'word_list' from 'words'
@drakelar1957
@drakelar1957 4 жыл бұрын
That's because you don't have the file
@mohammadahzemsiddique6396
@mohammadahzemsiddique6396 4 жыл бұрын
Sir I have a problem, a error is coming that cannot import name, import error, what shall I do, do U have messenger, can U text me there, or here no problem, my code is not working
@roushanraj2654
@roushanraj2654 4 жыл бұрын
Post the time from vid.... easier to view.
@Tweston3ny
@Tweston3ny 2 жыл бұрын
any help implementing *display_hangman(tries)*? i'm totally stuck thanks in advance
@thatgamer_2397
@thatgamer_2397 4 жыл бұрын
Does this work for the android app called Pydroid 3??
@perrymelenhorst6941
@perrymelenhorst6941 4 жыл бұрын
else: ^ IndentationError: expected an indented block Process finished with exit code 1 it keeps saying this when i try to do the "Not a valid guess" part.. WHat does it mean?
@nasajain
@nasajain 4 жыл бұрын
Perry Melenhorst Can you send the if statement as well, or whatever lines are before it until the corresponding if (just copy and paste it or something)❓
@thefactlord8820
@thefactlord8820 4 жыл бұрын
Great Vid. I used some techniques I learned, in my own vid! Great for a beginner
@codapi7441
@codapi7441 4 жыл бұрын
i got a syntax error: Traceback (most recent call last): File "/Users/Pillemers/Desktop/Rename.py", line 2, in from words import word_list ModuleNotFoundError: No module named 'words'
@AJ-jj1gs
@AJ-jj1gs 4 жыл бұрын
you have to create the module yourself. Like he stated he created the file already. If you create your own file within the same folder that your program is in and title it words and then create word_list within this file then you can import it like he is doing
@ademolaodusanya5678
@ademolaodusanya5678 2 жыл бұрын
Please how did you create that module using vs code
@rantinghippie6796
@rantinghippie6796 4 жыл бұрын
Does this work in Jupiter notebook? Trying to import the wordlist and it’s not working. Keeps saying module not found?
@wholesomedegenerate869
@wholesomedegenerate869 3 жыл бұрын
Thanks! A beginner here and I didn't understand everything but thanks!
@maya195
@maya195 2 жыл бұрын
how did u get that dark mode theme in python?
@tjw937
@tjw937 3 жыл бұрын
Is there a way to prompt a hint for each word? I made my own word list that's much shorter. 🤔
@ghosteditss4431
@ghosteditss4431 4 жыл бұрын
I keep getting a syntax error on line 2. Help?
@lplache
@lplache 4 жыл бұрын
Did you create the word file?
@37.vigneshgopal3
@37.vigneshgopal3 4 жыл бұрын
Hey, can't we like give a space between each letter in underscore?? its lil confusing. and btw can we print the answer at last if they don't guess t correct??
@vlkryvoided9674
@vlkryvoided9674 4 жыл бұрын
Click tab on your keyboard right above the caps lock key.
@aboynamedscienerd3524
@aboynamedscienerd3524 4 жыл бұрын
This is the first time I clicked to watch an ad.
@martonmagyar5840
@martonmagyar5840 Жыл бұрын
i keep getting line 2, in from words import word_list whenever is try to start the game
@aritrapal2870
@aritrapal2870 4 жыл бұрын
i searched it and absolutely loved it
@a7b641
@a7b641 4 жыл бұрын
Does Kite work on Visual Studio 2017? Not exactly VS Code
@KiteHQ
@KiteHQ 4 жыл бұрын
No, we only support VS Code at the moment. Please sign up to be notified when we have Visual Studio support: kite.com/letmeknow
@neucoarc
@neucoarc 3 жыл бұрын
I am a student at a python course, and as a little activity, they (my teachers) wanted us to make a hangman game. This video helped a lot! Huge thanks to you ❤❤ (Sorry for the bad english.)
@atbuivan35
@atbuivan35 4 жыл бұрын
why cant i import word_list???
@g.d.z_youtube
@g.d.z_youtube 3 жыл бұрын
Did not understand the line word = get_word() in the while loop in the main function. The word is already got value before the while loop so no one will win by the first guess word. Am I wrong?
@dzefir5895
@dzefir5895 4 жыл бұрын
Kite, how did you make your code open and you play?
@vlkryvoided9674
@vlkryvoided9674 4 жыл бұрын
Go to terminal on a mac, and type in the prompt "python (whatever you named the hangman file)" I'm not sure how to do it on windows though.
@pranaliparikh1292
@pranaliparikh1292 2 жыл бұрын
Great video but could you help me figure out why the file is opening on Sublime Text instead of initiating the game? Thank you
@Gioskar1
@Gioskar1 2 жыл бұрын
What if someone writes something different instead of "n" or "y" at the end of the game?
@mayedalshamsi
@mayedalshamsi 2 жыл бұрын
I think it ends the program. Either that, or an interdimensional gate opens, and satan comes out of it, riding a unicorn called Dave.
@DHTSciFiArtist
@DHTSciFiArtist 4 жыл бұрын
i have an error ImportError: cannot import name 'word_list' from 'words' (C:\ProgramData\Anaconda3\lib\site-packages\words.py)
@DHTSciFiArtist
@DHTSciFiArtist 4 жыл бұрын
import random from words import word_list def get_word(): word = random.choice(word_list) return word.upper() def play(word): word_completion = "_" * len(word) guessed = False guessed_letters = [] guessed_words = [] tries = 6 print("Let's play Hangman!") print(display_hangman(tries)) print(word_completion) print(" ") while not guessed and tries > 0: guess = input("Please guess a letter or word: ").upper() if len(guess) == 1 and guess.isalpha(): if guess in guessed_letters: print("You already guessed the letter", guess) elif guess not in word: print(guess, "is not in the word.") tries -= 1 guessed_letters.append(guess) else: print("Good job,", guess, "is in the word!") guessed_letters.append(guess) word_as_list = list(word_completion) indices = [i for i, letter in enumerate(word) if letter == guess] for index in indices: word_as_list[index] = guess word_completion = "".join(word_as_list) if "_" not in word_completion: guessed = True elif len(guess) == len(word) and guess.isalpha(): if guess in guessed_words: print("You already guessed the word", guess) elif guess != word: print(guess, "is not the word.") tries -= 1 guessed_words.append(guess) else: guessed = True word_completion = word else: print("Not a valid guess.") print(display_hangman(tries)) print(word_completion) print(" ") if guessed: print("Congrats, you guessed the word! You win!") else: print("Sorry, you ran out of tries. The word was " + word + ". Maybe next time!") def display_hangman(tries): stages = [ # final state: head, torso, both arms, and both legs """ -------- | | | O | \\|/ | | | / \\ - """, # head, torso, both arms, and one leg """ -------- | | | O | \\|/ | | | / - """, # head, torso, and both arms """ -------- | | | O | \\|/ | | | - """, # head, torso, and one arm """ -------- | | | O | \\| | | | - """, # head and torso """ -------- | | | O | | | | | - """, # head """ -------- | | | O | | | - """, # initial empty state """ -------- | | | | | | - """ ] return stages[tries] def main(): word = get_word() play(word) while input("Play Again? (Y/N) ").upper() == "Y": word = get_word() play(word) if __name__ == "__main__": main()
@nicholasmillington3624
@nicholasmillington3624 4 жыл бұрын
Hi, Very New to python i have grabbed the follow the script but is showing the following error: line 147, in main() NameError: name 'main' is not defined I am running on a Mac OS, will this be the issue? if so is there a way to resolve? Any feedback is welcome! Thank You, Nick
@c0ntinuous26
@c0ntinuous26 4 жыл бұрын
What color theme do you use in VS Code?
@Seth-ki9pb
@Seth-ki9pb 3 жыл бұрын
What IDE are you using
@camigaitan2131
@camigaitan2131 3 жыл бұрын
hey, can someone pls explain me what happens if I delete the last part if __name__ == "__main__": main() bc i don't get it
@shafatara4177
@shafatara4177 4 жыл бұрын
print(“AMAZING video!”)
@Nala-Potter
@Nala-Potter 3 жыл бұрын
code is really clear on a bigger screen awesome.
@magtrick6708
@magtrick6708 4 жыл бұрын
How do u add space behind each character and underscore?
@vlkryvoided9674
@vlkryvoided9674 4 жыл бұрын
click the tab button on your keyboard right above the caps lock key.
@sigurdbigset
@sigurdbigset 3 жыл бұрын
It didnt work for me. It just say: "No module named 'word'"
@abhinavsai1654
@abhinavsai1654 3 жыл бұрын
This video is legit awesome!! I love this!!!!!
@charlottealbrecht1415
@charlottealbrecht1415 3 жыл бұрын
What is the website u are using?
@MrSeinfeldFan2
@MrSeinfeldFan2 3 жыл бұрын
Hello, where is the code? I went to Git hub and there are at least 20 files, and some of them about a bunch of cr*** I am not interested in. Why could you not just separate the files we need to run the app? (just the 3 files)>
@JustinInBlack
@JustinInBlack 3 жыл бұрын
thanks, you saved my life
@jassgupta9115
@jassgupta9115 4 жыл бұрын
are you doing the coding in python script mode or interactive mode?
@zephyrius3210
@zephyrius3210 4 жыл бұрын
Help, I am getting an error, and I don't understand how to fix it: line 124 return stages[tries] ^ IndentationError: unindent does not match any outer indentation level Any ideas?
@AJ-jj1gs
@AJ-jj1gs 4 жыл бұрын
Simple to fix. Make sure that it is indented properly by matching the indentation of the other statements or assignments in that func definition
@nakitosmh
@nakitosmh 4 жыл бұрын
I tried this code but it doesn't display anything is this working in version 3.9? I'm just new in programming tho
@The_PinkKing
@The_PinkKing 2 жыл бұрын
What software is this?
@hafsahel-yakubu5123
@hafsahel-yakubu5123 4 жыл бұрын
Great video! However, when I ran the code.. it says the error: ..'set' object is not subscriptable, on lines 149..141 and 11. What could be the problem?
@KiteHQ
@KiteHQ 4 жыл бұрын
Thanks for watching and taking a stab at the project! It seems you may be using different code than we are. Our repo doesn’t contain that many lines of code, so we suggest copying the code from our Github and seeing if the code works for you: github.com/kiteco/python-youtube-code/tree/master/build-hangman-in-python
@AJ-jj1gs
@AJ-jj1gs 4 жыл бұрын
@@KiteHQ I copied and pasted the code and upon running the program it produces an error the first time any input whether it be a single character or a word is entered. For example I used "s" and it produced this NameError. return eval(raw_input(prompt)). File "" line 1, in . NameError: name 's' is not defined
@incognito4824
@incognito4824 3 жыл бұрын
Now, how do you separate those underscores to show the number of letters to be guessed?
@mayedalshamsi
@mayedalshamsi 2 жыл бұрын
You can try to set them as "_ ", so that each letter is represented by an underscore and a space.
@VocalsOfLocalsOfficial
@VocalsOfLocalsOfficial 4 жыл бұрын
that was nice, you made it look easy & speedy
@soumitramandal
@soumitramandal 4 жыл бұрын
Wow this was fun. Totally worth it.
@jetspray3
@jetspray3 2 жыл бұрын
There is one thing I don't understand. The statement len(guess) == len(word). Is it possible that as guess is made by the user would the letter be appended? I hope you respond.
Let's code a HANGMAN GAME in Python! 🕺
25:07
Bro Code
Рет қаралды 21 М.
All Top 40 Python Libraries EXPLAINED in 20 minutes
22:04
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
How To Code Hangman In Python | Tutorial For Beginners
16:26
Shaun Halverson
Рет қаралды 51 М.
How to Build a Hangman Game with Python
16:34
CBT Nuggets
Рет қаралды 33 М.
Creating A Simple Hangman Game in Python
10:06
NeuralNine
Рет қаралды 88 М.
Hangman Game in Python | Python Project #3 | Python Project for beginners #lec55
31:43
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН