Это видео недоступно.
Сожалеем об этом.

How to build HANGMAN with Python in 10 MINUTES

Поделиться
HTML-код
  • Опубликовано: 12 авг 2024
  • This Python tutorial for beginners shows you step-by-step how to build a basic command-line program: Hangman! The game will allow for user input, and will also output a visual of the hangman alongside the word that’s being guessed.
    ⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. We made this RUclips channel and Kite to help you be more productive: kite.com/download/?...
    ***************************************
    SUBSCRIBE for more Python tips, tutorials, and project breakdowns! ► ruclips.net/user/KiteHQ?sub_...
    JOIN our online community of people who want to level up their developer skills ►
    / 505658083720291
    Follow us on Twitter ► / kitehq
    ***************************************
    ADDITIONAL RESOURCES:
    Find the code from this tutorial here: github.com/kiteco/python-yout...
    6 Python Tips and Tricks YOU Should Know ►
    • 6 Python Tips and Tric...
    How to NAIL LeetCode Questions- Valid Parentheses ►
    • HOW TO NAIL LeetCode I...
    Sqlite 3 Python Tutorial in 5 minutes- Creating Database, Tables & Querying ► • Sqlite 3 Python Tutori...
    ***************************************
    Don’t forget to subscribe :)
    ruclips.net/user/KiteHQ?sub_...
    STAY TUNED:
    Kite ► kite.com/
    Twitter ► / kitehq
    RUclips ► / @kitehq

Комментарии • 477

  • @victoriatomokocountryman6129
    @victoriatomokocountryman6129 4 года назад +171

    I don't think I've ever clicked to watch an ad in my entire life until now; totally worth it.

  • @snowy8926
    @snowy8926 4 года назад +664

    I guess I'm the only person here who actually searched for this video lol

  • @DragonRazor9283
    @DragonRazor9283 3 года назад +98

    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  3 года назад +8

      So glad to we could save you, Vaiterius! Thanks for the love.

    • @littlesheep8644
      @littlesheep8644 3 года назад +3

      I'm having the same problem, what did you do?

    • @braddaily8688
      @braddaily8688 3 года назад +16

      @@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 2 года назад

      Me but i made mine before seeing this

    • @aydenshahraki1084
      @aydenshahraki1084 2 года назад

      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 года назад +35

    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!

  • @ianpimenta9197
    @ianpimenta9197 3 года назад +15

    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!

  • @bruinsmash8836
    @bruinsmash8836 4 года назад +145

    Cool video, a bit fast for a beginner, but overall very helpful.

    • @noobnub7305
      @noobnub7305 3 года назад

      for beginners, LMAO

    • @zestastic3359
      @zestastic3359 2 года назад +30

      @@noobnub7305 Creating hangman is a beginner coding project.

    • @friday8118
      @friday8118 2 года назад +5

      I was gonna say the same thing.

    • @writershard5065
      @writershard5065 Год назад +11

      @@noobnub7305 Always gotta have egotistical programmers in these comment sections lol.

  • @asdfasf
    @asdfasf 2 года назад +5

    brilliant video - thanks. My kids are learning at school and this will be very good to push their thinking.

  • @sylviasobol4815
    @sylviasobol4815 3 года назад +5

    What a great code! Thanks for posting, made my life so much easier when I compared it to my code )

  • @deotheoverlord
    @deotheoverlord 4 года назад +4

    This is really cool, thank you man!
    instantly subscribed to your channel.

  • @fumiya9078
    @fumiya9078 Год назад

    This is lightspeed compared to the other tutorials I watched and I love it

  • @bern1223
    @bern1223 3 года назад +3

    Amazing tutorial, thanks for the ad!

  • @thefactlord8820
    @thefactlord8820 4 года назад +7

    Great Vid. I used some techniques I learned, in my own vid! Great for a beginner

  • @Emmi_casei
    @Emmi_casei Год назад +1

    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...

  • @henningreichenbach4945
    @henningreichenbach4945 4 года назад +11

    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. ruclips.net/video/etSRnPp9H8s/видео.html

    • @neodong6060
      @neodong6060 2 года назад

      caaaaaaaaaaaaaaap. more python tutorials than there are js i believe

  • @soumitramandal
    @soumitramandal 4 года назад

    Wow this was fun. Totally worth it.

  • @jaganmayeesahoo4210
    @jaganmayeesahoo4210 4 года назад

    Am delighted to see it, thank you

  • @VocalsOfLocalsOfficial
    @VocalsOfLocalsOfficial 4 года назад

    that was nice, you made it look easy & speedy

  • @0_-
    @0_- 4 года назад +4

    This is the first video I saw of you!

  • @abhinavsai1654
    @abhinavsai1654 3 года назад

    This video is legit awesome!! I love this!!!!!

  • @AllTypeGaming6596
    @AllTypeGaming6596 4 года назад +7

    I see your ad in my feed lots time but i didn't click it 😅 and finally i click today

  • @KiteHQ
    @KiteHQ  4 года назад +161

    If you've scrolled down to the comments, let's play our own game of hangman...
    _ _ T _ _ _ _ P _ _ _ _

  • @Rich171090
    @Rich171090 2 года назад +1

    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

  • @pizzamccheese9278
    @pizzamccheese9278 3 года назад +3

    how do you draw the hangman's gallow thingy
    i.e. the stick on the left side and his body

  • @aritrapal2870
    @aritrapal2870 3 года назад

    i searched it and absolutely loved it

  • @KiteHQ
    @KiteHQ  4 года назад

    Like this video? Join the Kite Developer Community on Facebook for access to more resources + support from fellow Python developers. Time to level up! facebook.com/groups/505658083720291

  • @stephaniebeals5936
    @stephaniebeals5936 4 года назад +2

    how can you do word_as_list=list(word_completion) if word_completion is not introduced until later in the loop?

  • @ntrlshorts958
    @ntrlshorts958 3 года назад +2

    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?

  • @1979nige
    @1979nige 4 года назад +2

    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?

  • @ahmetsenol6104
    @ahmetsenol6104 Год назад

    You are so fast that i dont even want to do it anymore :D It was like trying to catch a bus.

  • @friday8118
    @friday8118 2 года назад

    This was quick af, I think I am gonna have to keep searching.

  • @guninchoudhary4921
    @guninchoudhary4921 3 года назад

    omg!! this works thanks for this video bro.

  • @benjamintunaru7214
    @benjamintunaru7214 4 года назад +5

    I really like your videos! thank you !

  • @wholesomedegenerate869
    @wholesomedegenerate869 3 года назад

    Thanks! A beginner here and I didn't understand everything but thanks!

  • @gyeumkim4536
    @gyeumkim4536 4 года назад +3

    I got error; Unable to import 'words' pylint(import-error) [2, 1] how to solve it?

  • @tuttorosso9903
    @tuttorosso9903 3 года назад

    Very clean!!

  • @Nala-Potter
    @Nala-Potter 3 года назад

    code is really clear on a bigger screen awesome.

  • @jaysonkxm3058
    @jaysonkxm3058 4 года назад +4

    I tried to import the word list from your code using the exact same thing I cant.

  • @alfredvonhofsten4010
    @alfredvonhofsten4010 3 года назад +21

    this man. types. pretty fast

  • @mohammadamintorabi8415
    @mohammadamintorabi8415 Год назад +1

    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?

  • @tjw937
    @tjw937 3 года назад

    Is there a way to prompt a hint for each word? I made my own word list that's much shorter. 🤔

  • @maedevaezi4428
    @maedevaezi4428 3 года назад

    Thanks for this, so helpful.Can you make one with the appjar gui version please

  • @1UPBR0
    @1UPBR0 3 года назад

    Hey, I'm having trouble with lining up my code. Do you have any tips?

  • @jassgupta9115
    @jassgupta9115 4 года назад

    are you doing the coding in python script mode or interactive mode?

  • @JustinInBlack
    @JustinInBlack 2 года назад

    thanks, you saved my life

  • @rantinghippie6796
    @rantinghippie6796 4 года назад

    Does this work in Jupiter notebook? Trying to import the wordlist and it’s not working. Keeps saying module not found?

  • @seenivasagans5399
    @seenivasagans5399 4 года назад +2

    thank you

  • @Nobody-xp6ip
    @Nobody-xp6ip 7 месяцев назад +1

    I made a version of Hangman similar to this but without the visual hanging man.
    In mines, there is a hint system as well

  • @heyman7891
    @heyman7891 3 года назад

    If you have a plain list of words how do you implent this ' and this , symbol on every word??

  • @c0ntinuous26
    @c0ntinuous26 4 года назад

    What color theme do you use in VS Code?

  • @Tweston3ny
    @Tweston3ny 2 года назад

    any help implementing *display_hangman(tries)*? i'm totally stuck thanks in advance

  • @thatgamer_2397
    @thatgamer_2397 3 года назад +1

    Does this work for the android app called Pydroid 3??

  • @martonmagyar5840
    @martonmagyar5840 9 месяцев назад

    i keep getting line 2, in
    from words import word_list whenever is try to start the game

  • @myke6972
    @myke6972 2 года назад +1

    i dont get the indices part, maybe because im new, idk, can someone pls explain me.

  • @nicholasmillington3624
    @nicholasmillington3624 3 года назад

    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

  • @froxy_vn1342
    @froxy_vn1342 Год назад +2

    The first part with the word list doesnt work what can i do

  • @ademolaodusanya5678
    @ademolaodusanya5678 Год назад

    Please how did you create that module using vs code

  • @billychan9065
    @billychan9065 3 года назад +81

    "simple hangman game" [cry]

    • @ounsspace2573
      @ounsspace2573 3 года назад +3

      It's so hardddddddddddd(cryyyyyyyyyyyyyyyyyyyyyyyyyyyyyy)

  • @akankshayeola3472
    @akankshayeola3472 3 года назад +6

    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 2 года назад +1

      Its because of function enumirate()

  • @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?

  • @ihebbenali2745
    @ihebbenali2745 3 года назад +15

    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 года назад +1

      @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?

  • @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

  • @nakito8398
    @nakito8398 3 года назад

    I tried this code but it doesn't display anything is this working in version 3.9? I'm just new in programming tho

  • @Spongebob_Squarepants
    @Spongebob_Squarepants 4 года назад +3

    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.

  • @EduardoRodrigues-hl7ne
    @EduardoRodrigues-hl7ne 3 месяца назад

    Great video!!!!!!!!!!!!!!

  • @aboynamedscienerd3524
    @aboynamedscienerd3524 4 года назад +6

    This is the first time I clicked to watch an ad.

  • @ainish4940
    @ainish4940 4 года назад +1

    anyone got the whole source code and can paste it either here or in pastebin with words and the code for the game thank you very much

  • @raksjdsm1234
    @raksjdsm1234 Год назад

    for some reason I don't understanding why it is say invalid syntax in line 1

  • @james2529
    @james2529 4 года назад +2

    oh wow I was playing around trying to make this myself today and I got stuck about how to replace a letter at the right index. I didn't know you could just do [index] ! I am both happy with myself for getting all the way to that point and a little annoyed i didn't know about that function

  • @Wabuh-Wabuh
    @Wabuh-Wabuh 3 года назад +2

    Can we have more walkthrough videos? I learn best that way. it allows me to correlate code with actions visually. PLS!!!

  • @maya195
    @maya195 Год назад

    how did u get that dark mode theme in python?

  • @jetspray3
    @jetspray3 Год назад

    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.

  • @typeshit0
    @typeshit0 4 года назад +2

    Can you make it so that a user can type in a word, and the other user has to guess it

  • @ilijanedelkovski3201
    @ilijanedelkovski3201 3 года назад

    hey i tried this and it says that return stages[tries] is an unexpected indent

  • @Paapathikids
    @Paapathikids 4 года назад

    What is the difference between pytest and python selenium

  • @Abdullah-Alhariri
    @Abdullah-Alhariri 3 года назад

    thanks dude

  • @ghostmighty8729
    @ghostmighty8729 4 года назад

    hey i wanted to know if there is a way to import it to a discord bot ?

  • @camigaitan2131
    @camigaitan2131 2 года назад

    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 3 года назад +4

    print(“AMAZING video!”)

  • @CHILLAXING
    @CHILLAXING 4 года назад +4

    This was a great video! Can you go a little slower next time? Thank you. :)

  • @paratiel4295
    @paratiel4295 4 года назад +1

    love it

  • @timothyivanov9447
    @timothyivanov9447 4 года назад +2

    THIS DUDES WRITING IS GOD SPEED ALIN

  • @samchandagames7602
    @samchandagames7602 2 года назад

    for some reason I keep getting errors on this one line of code: return stages[tries]

  • @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)>

  • @charlottealbrecht1415
    @charlottealbrecht1415 3 года назад

    What is the website u are using?

  • @benedikt7846
    @benedikt7846 3 года назад +2

    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 "_".

  • @meaghangallagher6020
    @meaghangallagher6020 3 года назад

    i'm having trouble playing again. when input why, the game just stops. any ideas?

  • @Seth-ki9pb
    @Seth-ki9pb 2 года назад

    What IDE are you using

  • @coderutkrishthpython7244
    @coderutkrishthpython7244 3 года назад

    by some problem its showing "No module named word "
    please help!

  • @t-e-hexo
    @t-e-hexo 3 года назад

    darn i cant use kite my cpu does not support the avx instruction set :(

  • @mrsteampunkoctopus6524
    @mrsteampunkoctopus6524 3 года назад +1

    I am using this for a Computer Science project

  • @caleb-fg1nl
    @caleb-fg1nl 2 года назад +1

    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

  • @aasshmangupta9553
    @aasshmangupta9553 2 года назад

    can you make a list of all the commands of codes in python (not the one used in this) and send the link in your video discription. also i would really appreciate it a lot!

  • @jennifersandford9059
    @jennifersandford9059 4 года назад

    which version of python r u using

  • @humanbean1203
    @humanbean1203 3 года назад

    how do you get that word list

  • @snvarbjarki1942
    @snvarbjarki1942 3 года назад

    how did you make the man on 7.14

  • @kiavash_483
    @kiavash_483 4 года назад

    Great!!!!!!!!

  • @atbuivan35
    @atbuivan35 4 года назад +1

    why cant i import word_list???

  • @atbuivan35
    @atbuivan35 4 года назад

    its seem like the package names word_list doesnt exist

  • @dzefir5895
    @dzefir5895 4 года назад +1

    Kite, how did you make your code open and you play?

    • @vlkryvoided9674
      @vlkryvoided9674 3 года назад

      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.

  • @mostaphamansoor3969
    @mostaphamansoor3969 4 года назад

    how do i get the words the txt file