How to Code a Game of Hangman... The EASY Way!! (Beginner Python Tutorial)

  Рет қаралды 107,672

Kylie Ying

Kylie Ying

Күн бұрын

Пікірлер: 207
@KylieYYing
@KylieYYing 4 жыл бұрын
**NOTE: in the words function, you should add a ".upper()" to "return word" so that everything is uppercased Update: lol i'm thinking about redoing this video. comment below if you think that's a good idea For more coding ideas, projects, and tutorials, be sure to subscribe! --> kzbin.info ~~~~~~~~~~~~~~~~~~~~~~~~ Source code: github.com/kying18/hangman ~~~~~~~~~~~~~~~~~~~~~~~~ Follow me on Instagram: instagram.com/kylieyying Follow me on Twitter: twitter.com/kylieyying
@hi-hi-here
@hi-hi-here 4 жыл бұрын
I think you should re-do it because next time you can be more proficient and specific, which is always something beginners need. And if you can also show how to play the game again without having to re-run the program.
@laughing-out-loudhd996
@laughing-out-loudhd996 3 жыл бұрын
Like ya alot !..
@lahocoschimocotaesdesteusj559
@lahocoschimocotaesdesteusj559 3 жыл бұрын
@@laughing-out-loudhd996 bruhhhhhhhh
@farahmohumad5355
@farahmohumad5355 3 жыл бұрын
thanks for upload
@faisalkhan_09
@faisalkhan_09 3 жыл бұрын
It throw error Cannkt import name words from word
@leeroy77
@leeroy77 4 жыл бұрын
Great tutorial. You carefully explain each step and why you're doing it. Perfect for a beginner. Unfortunately, a lot of "beginner" tutorials just race through and write lots of code and don't take time to pause and explain what's happening and why which is exactly what a tutorial is supposed to do.
@KylieYYing
@KylieYYing 4 жыл бұрын
Thank you :)
@Steven-ez6qp
@Steven-ez6qp 6 ай бұрын
​@@KylieYYingHi ❤️ Hangman Such a fun game! I play Hangman with my niece and let her win and she 🤭🤣 and says yaaa I got to Hang a bad guy lol Soo funny and cute wouldn't you agree with me?
@Jan_Jan_
@Jan_Jan_ 3 жыл бұрын
Thanks so much! As a beginner, it took me way longer than 10 mins to fully understand the logic. But, once it clicked, it all made sense! :D
@lijoso2573
@lijoso2573 4 жыл бұрын
First: thank you very much. second - i'm beginner python program , so i try again to code hangman program or start from beginning. i'm also old man 63/yrs old , i never program my life , but i never give up , because it helps me to be active. thank you very much.
@KylieYYing
@KylieYYing 4 жыл бұрын
That's amazing! Hangman is actually a pretty difficult project when you're a complete beginner. I would recommend watching my beginner series and following the beginner tutorials i have on there first: kzbin.info/aero/PLkWv3oO4kHnuKi032yRRYgyQ4kgaNp6gs
@emyrdaniela6037
@emyrdaniela6037 4 жыл бұрын
Thank you for this. This is exactly what I needed to see. I am doing intro to Python at Uni and we have a test in a few days. They gave us a practice test which is based on Hangman and yours pretty much covers the parameters of the practice. So I will use this to help me study up for the test.
@KylieYYing
@KylieYYing 4 жыл бұрын
Glad I could help! :) You should also check out my tic-tac-toe tutorial. It might help with figuring out logic, especially if you’re trying to code games!
@emyrdaniela6037
@emyrdaniela6037 4 жыл бұрын
Y Cubed Guess what next weeks practical is? Tic tac toe haha. I’m subscribing. Thank you! We did a simple logic simulator last week and that was head gymnastics for me.
@KylieYYing
@KylieYYing 4 жыл бұрын
Emry Daniels haha perfect! You can even step it up a notch because my tic tac toe implementation includes a simple algorithm that can make it unbeatable!
@nimanizky
@nimanizky 4 жыл бұрын
watch ton of video teach by mit people and all i know is that you all has super clarity fo teaching something and simple!
@kapach1000
@kapach1000 4 жыл бұрын
i love the logic on how u approached the game. will try it
@arjun_sanjeev
@arjun_sanjeev 4 жыл бұрын
Love the way you clearly explain what each line of code does. Great for beginners like me.
@jitendrachhetri147
@jitendrachhetri147 3 жыл бұрын
Thanks Kylie for your great , easy-to-understand lesson for beginners like me. To make it a bit easier, I added 'Hint' option. It was fun :)
@mrgintl
@mrgintl 4 жыл бұрын
Really like your teaching style. I will check out more of your videos.
@tigressshah8904
@tigressshah8904 2 жыл бұрын
the best tutorial i have found till now very helpful in understanding
@divinejojolola6632
@divinejojolola6632 2 жыл бұрын
at 6:04 i run the code and even keep hangman() at the end of the code but nothing appears on my output. I ran it on pycharm and python idle. same result
@Pranav6.626
@Pranav6.626 5 ай бұрын
same here
@kathleenbeltran4210
@kathleenbeltran4210 4 жыл бұрын
I'd love to see a tutorial on how to make an advanced game of Hangman
@ben-zz2rm
@ben-zz2rm 2 жыл бұрын
Ben here Kylie. Sorry, worked out my problem...Forgot to end the routine with a closing function..hangman()..All good and keep up the good work.
@hadireg
@hadireg 3 жыл бұрын
nice little project... i'm crash learning python for a personal project and as I'm an old time programmer in old languages :) I discover the nice features described here in python dealing with strings when doing (alphabets - used_letters) 😊 I"m not used to have everything ready for me while rather thinking all the time I need to add it myself to the code. just need to know what's avail to make use of...
@medalikhaled
@medalikhaled 3 жыл бұрын
your tutorials are just fun to watch, you deserve more than 10k
@KylieYYing
@KylieYYing 3 жыл бұрын
Thanks :) I’m trying hahaha
@footballizlyfe
@footballizlyfe 3 жыл бұрын
can change lives to lives = len(word_letters) + 2 so that it has 2 more tries than the unique letters that are in the word
@guersomfalcon7544
@guersomfalcon7544 4 жыл бұрын
8:30 There is a problem, on line 33 you are trying to find a capital letter within a set of lowercase letters.
@KylieYYing
@KylieYYing 4 жыл бұрын
Yes, I realized that. If you look in the description I actually make a note of that. Sorry, my mistake!
@ViniciusRaphael
@ViniciusRaphael 4 жыл бұрын
On line 22 you write: if user_letter in alphabet - used_letters: What alphabet - used_letters means? I understand user_letter in alphabet or alphabeth in user_letters. But both together, I`m not sure I understand.
@KylieYYing
@KylieYYing 4 жыл бұрын
You can think of alphabet - used_letters as a literal subtraction! It’s all the letters in the alphabet minus the used letters (so basically all the unused letters). We can do this because both of these are sets; it’s the difference of the sets. Hope that clears things up!
@ViniciusRaphael
@ViniciusRaphael 4 жыл бұрын
First of all thank you for answering. Now that you explained makes total sense. Btw thanks for the video, I`m learning Python and having the opportunity to check the logic on the process helped me a lot.
@KylieYYing
@KylieYYing 4 жыл бұрын
No problem! I’m going to make more tutorials in the future :) You should subscribe and check them out!
@thelmalaryea5723
@thelmalaryea5723 4 жыл бұрын
Hello!please I am having challenges with the code.The dashes in a word are printing alright but the guessed letters are not printing even though it is in the word.I have crosschecked several times but I can't find the error
@KylieYYing
@KylieYYing 4 жыл бұрын
Is it a lowercase uppercase issue?
@thelmalaryea5723
@thelmalaryea5723 4 жыл бұрын
@@KylieYYing No please because the upper case is working
@lijoso2573
@lijoso2573 4 жыл бұрын
Hey: i get invalid syntax (if user_letter in alphabet - used_letters:) line 33
@swapnitam
@swapnitam 3 жыл бұрын
The video was great and very helpful as I am a beginner. I am using IDLE to write and run the script. When i run the module nothing happens. After searching I added following lines that helped me to run the script: def main(): hangman() if __name__ == "__main__": main() Can you tell me how it runs for you without this? What am I missing?
@kristencallan8096
@kristencallan8096 2 жыл бұрын
I had that same issue and had to look at her linked source code. That was the only way it worked for me.
@mathsmagician6949
@mathsmagician6949 4 жыл бұрын
I have a question. How could I integrate levels(easy = 10 lives, medium = 8 lives and hard =6) and the actual hangman phases like the one you draw?
@KylieYYing
@KylieYYing 4 жыл бұрын
You could pass these in and then adjust the lives accordifnly
@hanhtooaein6368
@hanhtooaein6368 Жыл бұрын
What's the function of 'alphabet' variable in this hangman game?
@_thesunflowerfairy_
@_thesunflowerfairy_ 3 жыл бұрын
You have taught me way more than my teacher has
@bananaboydan3642
@bananaboydan3642 2 жыл бұрын
5:05 how does the minus sign indicate whether you used the word or not?
@bananaboydan3642
@bananaboydan3642 2 жыл бұрын
please help im stuck
@alexwu7111
@alexwu7111 4 жыл бұрын
hey I'm a beginner! This tutorial is the best one I have ever seen before. I literily understood what you said on this video! Is awesome! I wish I can make a game like you. :))
@KylieYYing
@KylieYYing 4 жыл бұрын
Yay happy to hear that!
@lahocoschimocotaesdesteusj559
@lahocoschimocotaesdesteusj559 3 жыл бұрын
bruhhhhhhhhhh
@lazarorojas2742
@lazarorojas2742 4 жыл бұрын
Hi, i have a question on the line 33, what does do this symbol "-" or just - , as i can see it works as a logical operator "and". Please, tell if i am wrong.Good video though, i've already click the button like.
@KylieYYing
@KylieYYing 4 жыл бұрын
No, so you can think of that as like sept subtraction. It’s alphabet minus used letters (ie unused letters)
@lazarorojas2742
@lazarorojas2742 4 жыл бұрын
@@KylieYYing Oh, thank you so much. i'm new on this so i get confused when i saw that.
@FA-sy7ew
@FA-sy7ew 2 жыл бұрын
How does the code match the position(index) of the letters?
@bismo5268
@bismo5268 4 жыл бұрын
I've literally copied basically everything but it still doesn't run properly. All I get is after entering a letter it says 'process finished with exit code 0'. There's no 'current word' or 'used letters' or anything and it doesn't loop.
@arjunmauji6379
@arjunmauji6379 4 жыл бұрын
did you call the function at the end of your program ---> hangman()
@kulsumkhan8283
@kulsumkhan8283 3 жыл бұрын
Hi Kylie. I am new to Python. Your tutorial is really easy to follow and is very clear and concise. Unfortunately I'm slightly struggling as my code is not running properly. I have followed exactly how you have done it. But I keep getting problem: Shadows name 'words' from outer space. I don't understand why that's happening when it worked fine on your. Could you please suggest me how to fix it. Thank you.
@glowria_balla4332
@glowria_balla4332 2 жыл бұрын
Having same issue
@simbian4345
@simbian4345 3 жыл бұрын
5:00 What is that ' - ' do?
@charlie6618
@charlie6618 4 жыл бұрын
0:26 was that veni johanna?
@galaxyfan7883
@galaxyfan7883 4 жыл бұрын
Hi, I couldn’t open it on my macbook’s terminal and played it from here. How can I open my files in terminal?
@Aabhusan7
@Aabhusan7 2 жыл бұрын
#help In 22 line we can use (not in) instead of (-) right?
@ItachiUchihaJoker
@ItachiUchihaJoker 3 жыл бұрын
Great tutorial! But I have a question. So let's say you do not want to import the list (with words), but want to paste it in the same .py file,, How should i do that??
@KylieYYing
@KylieYYing 3 жыл бұрын
You can just copy the "words = [...]" line into the file instead of importing it
@laksh._.official
@laksh._.official 3 жыл бұрын
How can I add a function which tells me the score which is guess remaining * the unique letters in the word
@Cyan1de.
@Cyan1de. 3 жыл бұрын
for some reason im not able to find the list of words... could u provide me with the link please?
@DreamEvilGaming
@DreamEvilGaming 3 жыл бұрын
it says that theres like an error in line 2 what does that mean?
@bahai02
@bahai02 4 жыл бұрын
Viral karo bandi ko, bohot mast samjhati hai bdw, lots of love from India
@Moonblanc
@Moonblanc 4 жыл бұрын
Hello @Kylie Ying I am having trouble with the code as I keep getting indentation errors on lines 47 and above. Furthermore the program does not place in any words to replace the dashes. please I need ur help urgently
@ninjabathat2792
@ninjabathat2792 4 жыл бұрын
Not sure if you will response, but do you mind explaining the last line of code? if __name__ == '__main__': hangman() not sure what this means but imma assume that it calls the function to run it correct?
@KylieYYing
@KylieYYing 4 жыл бұрын
Yeah definitely, good question. This if-statement is good coding practice for when you have multiple files and larger projects. Basically, this if-statement is telling the computer to only run the stuff after it if it's the file being run (ie if you call 'python3 main.py' or something). However, when we're dealing with multiple files, we don't necessarily want to run these extra lines of code when we run a different file that imports from this one.. something like that. Does this make any sense? You can test this out for yourself with two python files, lets call then main.py and secondary.py. Import secondary.py into main.py. Try having print statements in secondary.py both in the if-statement and outside of it. Then, run main.py and see what gets printed. Run secondary.py and see what gets printed.
@duroka787delapeli
@duroka787delapeli Жыл бұрын
hello Kylie, when you write after the hashtag (#) what does it mean? thank you in advance
@kaberanshutisamuel1856
@kaberanshutisamuel1856 Жыл бұрын
I am not kylie, but let me answer you, you use hashtag when you want python to ignore whatever you write after it so you can use it just for taking notes in your code 🤪🤪
@duroka787delapeli
@duroka787delapeli Жыл бұрын
@kaberanshutisamuel1856 cool explanation thank you 🙏
@karenstewart8531
@karenstewart8531 4 жыл бұрын
I have redid the code three times...same error. It is telling me that the variables are undefined pylint(undefined-variable) even though I can see that they are defined. Any help??
@Nedwin
@Nedwin 3 жыл бұрын
Kylie you are a Rockstar!!
@Hsalz
@Hsalz 6 ай бұрын
Great tutorial. Thanks queen!
@איילשיימן-ר2כ
@איילשיימן-ר2כ 2 жыл бұрын
Wow you explained it so well to beginners thank you!!!
@therabidpancake1
@therabidpancake1 2 жыл бұрын
okay I am getting a bit confused . The words after the hashtag are not required but you write # '-' join [] I do understand that you are trying to label everything as you go
@themegayoutuber
@themegayoutuber 4 жыл бұрын
Can you use any words, or does it have to be the ones you used?
@whatiscooler
@whatiscooler 4 жыл бұрын
Thank you so much for this excellent tutorial!!
@rondacorkhill1654
@rondacorkhill1654 4 жыл бұрын
Thank you so much for putting these together. I did the entire code but it's not recognizing the letters. Do I need to attach and alphabet file? In both returned words I had letters I guessed.
@KylieYYing
@KylieYYing 4 жыл бұрын
Are you talking about return_word? I accidentally left out the .upper() in there, so check that you have it. It’s likely comparing a lowercase letter to uppercase letter and not recognizing it!
@rondacorkhill1654
@rondacorkhill1654 4 жыл бұрын
@@KylieYYing Yup, that was it. I didn't see your earlier reply. Thank you! My old brain is trying to reject learning python and Arcade.
@KylieYYing
@KylieYYing 4 жыл бұрын
You got this :) For a step up from hangman you should check out my unbeatable tic tac toe tutorial! Or if you want a basic crash course, I should be uploading one today or tomorrow!
@nabilovhic
@nabilovhic 4 жыл бұрын
if anyone still see this guys i made the whole game but there is something wroung when i enter a letter it doesnt appear in blanks if it's right how to fix that?
@enciuraluca3100
@enciuraluca3100 4 жыл бұрын
Hi, I dont understand exactly what this line of code works "word_list = [letter if letter in guest_letters else '-' for letter in word]". How to create the connection between "letter" (from this line of code) and the letter we need to guess from the word?
@KylieYYing
@KylieYYing 4 жыл бұрын
This is a list comprehension. I’m trying to make the word a list of letters right here so “word” becomes [“w”, “o”, “r”, “d”]. The text inside the brackets is saying for every letter in word, append that letter to the list if the letter is in the list of guessed letters, otherwise append “-“.
@enciuraluca3100
@enciuraluca3100 4 жыл бұрын
@@KylieYYing THANK YOUUUU
@lahocoschimocotaesdesteusj559
@lahocoschimocotaesdesteusj559 3 жыл бұрын
@@enciuraluca3100 bruuuuuuuuuhhhhhhhh
@ben-zz2rm
@ben-zz2rm 2 жыл бұрын
Great explanation for your hangman script. Kylie. Am having issues running what I have done so far. When I hit run, nothing happens! Can you see where I have made mistake/s please. Note: I had to import the string module because it would not recognize it otherwise. Much obliged from Australia Ben import random # needs to be imported if used in routine import string from words import words # this list of words must be in .py format def get_valid_word(words): word = random.choice(words) # will randomly choose a word from the list in "words" file while "-" in word or " " in word: word = random.choice(words) return word.upper() def hangman(): word = get_valid_word(words) word_letters = set(word) # the letters in the word alphabet = set(string.ascii_uppercase) used_letters = set() # the user has guessed the letters while len(word_letters) > 0: user_letter = input(" Guess a letter: ").upper() if user_letter in alphabet - used_letters: used_letters.add(user_letter) if user_letter in word_letters: word_letters.remove(user_letter) elif user_letter in used_letters: print("You have already used that letter. Please try again. ") else: print("Invalid character Blockhead !. Only select letters from the alphabet. Try again. ")
@corinx
@corinx 4 жыл бұрын
Hey! This video was great !!! but, just one small ajustment pls, i really liked the #....... so i would really like to see that for more of the lines, im a begginer so im kinda dumb. Anyways thxxxxxxxxxxx
@KylieYYing
@KylieYYing 4 жыл бұрын
The comments? Sure
@rishikapoor9787
@rishikapoor9787 4 жыл бұрын
please help to explain this line "word_list = [letter if letter in used_letters else '-' for letter in x]", you have written in one line but if i were to understand in 2-3 lines of code what does it mean. thank you so much.
@KylieYYing
@KylieYYing 4 жыл бұрын
This is a list comprehension Word_list=[] For letter in x: If letter in used_letters: Word_list.append(letter) Else: Word_list.append(‘-‘)
@bandit8258
@bandit8258 3 жыл бұрын
@@KylieYYing sorry but how does this line of code help the "letter" to arrange in the correct order? like at 8:30, when you type "E", the "E" immediately goes to the last word under current word, how does it know what is the correct sequence?
@moodyehab1214
@moodyehab1214 3 жыл бұрын
I did exactly as you did but it keeps saying unused variables and undefined variables
@lahocoschimocotaesdesteusj559
@lahocoschimocotaesdesteusj559 3 жыл бұрын
lol
@helloworld6947
@helloworld6947 2 жыл бұрын
my wordlist not showing used_letters
@kreeeooo
@kreeeooo 4 жыл бұрын
Can you send me a link to those list of words please?
@KylieYYing
@KylieYYing 4 жыл бұрын
Check the github link. It should be in there
@mayurravindra9433
@mayurravindra9433 4 жыл бұрын
Awesome❤ Would love to try it now!!
@guersomfalcon7544
@guersomfalcon7544 4 жыл бұрын
8:30 I don't understand line 27. I never saw anything like this in Python.
@KylieYYing
@KylieYYing 4 жыл бұрын
That’s a list comprehension but with an if/else statement! Basically it’s saying for every letter, if the letter is in used letters, then use the value of the letter otherwise use “-“. Here’s the expanded equivalent: letters = [] For letter in word: if letter in used_letters: letters.append(letter) else: letters.append(“-“) Does that make more sense?
@guersomfalcon7544
@guersomfalcon7544 4 жыл бұрын
Y Cubed Yeah, thanks.
@homenick93
@homenick93 4 жыл бұрын
So I’m a complete beginner I have seen beginner courses in python already I was a little lost when you did things in terminal are actually supposed to do tasks in terminal to complete this?
@KylieYYing
@KylieYYing 4 жыл бұрын
I run my scripts in terminal but there are other ways that you can run them. I just prefer terminal so I know exactly where I'm running the script from and it's independent of the text editor you use. I'd like to point you to my beginner python series. In the first video (after python download/installation) I talk a bit about how to run your code in terminal and how the pieces (ie terminal, text editor, python) go together: kzbin.info/aero/PLkWv3oO4kHnuKi032yRRYgyQ4kgaNp6gs
@homenick93
@homenick93 4 жыл бұрын
Ohhhhh wait a second you meant the terminal in python
@lahocoschimocotaesdesteusj559
@lahocoschimocotaesdesteusj559 3 жыл бұрын
@@homenick93 bruh this is advanced, or intermediate, thats like im learning how to print hello world and i wanna know how to code tic tac toe MAN WAKKKKE UPPPP
@errykocalumag4579
@errykocalumag4579 3 жыл бұрын
maam whats the difference between " " and ' ' is there any difference between them?
@KylieYYing
@KylieYYing 3 жыл бұрын
No difference in Python, both are strings
@codapi7441
@codapi7441 4 жыл бұрын
Which website are you coding on?
@lahocoschimocotaesdesteusj559
@lahocoschimocotaesdesteusj559 3 жыл бұрын
its not a site, its pycharm, download it
@Userisnmuh
@Userisnmuh 3 жыл бұрын
thank you vey much for all of your tutorials, it's helping me a lot :thumbs up:
@KhalilYasser
@KhalilYasser 3 жыл бұрын
Amazing tutorial. Thanks a lot.
@SuperFirstSerg
@SuperFirstSerg 4 жыл бұрын
thx for the hangman video,it was very helpful😀
@KylieYYing
@KylieYYing 4 жыл бұрын
Glad it helped!
@SuperFirstSerg
@SuperFirstSerg 4 жыл бұрын
@@KylieYYing which sites do you recommend for learning python ?
@KylieYYing
@KylieYYing 4 жыл бұрын
MIT opencourseware has some lectures if you want to learn the fundamentals beyond how to code.. but if you’re like me and you like doing more than listening, you can also check out codecademy!
@SuperFirstSerg
@SuperFirstSerg 4 жыл бұрын
@@KylieYYing thanks , I'm currently doing a specialisation in python at coursara and after that I'm to learn in Codecademy a course that focuses on data analysis with python . Thanks for the suggestion , I always looking for new sites to learn from.
@subhodipdas652
@subhodipdas652 4 жыл бұрын
That list contains 2466 words to be exact, it doesn't have 5000 words as it mentioned Great tutorial btw!
@KylieYYing
@KylieYYing 4 жыл бұрын
Thank you! Good catch!
@lijoso2573
@lijoso2573 4 жыл бұрын
Hi Kylie Ying : I already install-----> pip install random-word ---> and successful installs , but still i get Error ---> Traceback (most recent call last): File "C:\python\Python37\Hangman program.py", line 2, in from words import words ModuleNotFoundError: No module named 'words' even i install , alpha words and words dictionary , but still in not working , what can i do more, please help
@KylieYYing
@KylieYYing 4 жыл бұрын
It’s not a package, it’s a separate file. Please check out this video: kzbin.info/www/bejne/fWnRpGV-rdWAZrc
@ogaimon3380
@ogaimon3380 Жыл бұрын
love your videos
@lijoso2573
@lijoso2573 4 жыл бұрын
Hi Kylie Ying: now i get this problem --->>Traceback (most recent call last): File "C:\python\Python37\Hangman program.py", line 2, in from words import words ModuleNotFoundError: No module named 'words' ---> so how can i solve this problem, please help. thank you
@KylieYYing
@KylieYYing 4 жыл бұрын
You need to have a file words.py where words is a variable in that file. I have the words variable as a list of words. So this statement, from words import words, it's saying look at the words.py file (from words), and get the words variable so that we can access it in our current file (import words)
@josebarreto6694
@josebarreto6694 4 жыл бұрын
Thanks so much I learned a lot!
@meshalalsaeed1268
@meshalalsaeed1268 4 жыл бұрын
what a great simple way to explain gd job ..... keep it up
@laughing-out-loudhd996
@laughing-out-loudhd996 3 жыл бұрын
Underated Channel ! !... .. keep being awesome... Q: what IDE u using ?
@lahocoschimocotaesdesteusj559
@lahocoschimocotaesdesteusj559 3 жыл бұрын
Pycharm
@lijoso2573
@lijoso2573 4 жыл бұрын
how can i solve this syntax - if user_letter in alphabet - used_letters:
@KylieYYing
@KylieYYing 4 жыл бұрын
Syntax seems fine, depends what the specific issue you're having is
@lijoso2573
@lijoso2573 4 жыл бұрын
@@KylieYYing :
@lijoso2573
@lijoso2573 4 жыл бұрын
user_letter = input("Guess a letter:".upper() used_letters.add(user_letter) if user_letter in word _letters: word_letters.remove(user_letter) print("")
@KylieYYing
@KylieYYing 4 жыл бұрын
Well you’re missing the closing parentheses in the first line and you have an extra space in a variable name in the third line...
@hichourap1781
@hichourap1781 4 жыл бұрын
Awesome video ❤️ , Thank you
@KylieYYing
@KylieYYing 4 жыл бұрын
:)
@chanakyaks3936
@chanakyaks3936 4 жыл бұрын
Just loved it❤️
@jameskulu
@jameskulu 4 жыл бұрын
Great video. I love it Please make more videos like this I would be more happy if you upload some django stuffs
@KylieYYing
@KylieYYing 4 жыл бұрын
Thank you! You should check out my latest video - it is a tutorial on flask and how to integrate backend into a website. Today, in approx 45 mins, I am releasing a video on VueJS and how to code front-end for a website using Vue! Make sure to subscribe for more videos - I'll see what I can do with django.
@jameskulu
@jameskulu 4 жыл бұрын
@@KylieYYing okay thanks a lot
@KylieYYing
@KylieYYing 4 жыл бұрын
Hey, I’m considering using Django to create a new page on my website that allows people to enter feedback or something similar to that.. would that be a tutorial you’d like to see?
@jameskulu
@jameskulu 4 жыл бұрын
@@KylieYYing yes of course. It will be great too see that :)
@alex-lk7sq
@alex-lk7sq Жыл бұрын
make a variable (v) set to 0 then while turns>0: for l in chosenwords : if l in theletter: count = count +1 print (l,end="") else: print ("_",end="") v += 1 for a easy way to print _
@mathsmagician6949
@mathsmagician6949 4 жыл бұрын
Really great video, thanks a lot
@prateek9405
@prateek9405 6 ай бұрын
mine didnt work
@leelamaruthisrikakulapu7325
@leelamaruthisrikakulapu7325 2 жыл бұрын
Thanks a lot Kylie Ying
@rebegg99
@rebegg99 4 жыл бұрын
Great tutorial!
@rebegg99
@rebegg99 4 жыл бұрын
I think something went wrong in my code, though, as i tried all the letters in the alphabet and it said that they were all wrong.
@KylieYYing
@KylieYYing 4 жыл бұрын
check the case of the letters (check out my pinned comment)
@sunnyfreedomfighter
@sunnyfreedomfighter 4 жыл бұрын
Thanks alot for the video!!!! i tried to make the game on my own...failed!!....thanks again...keep safe...from london :D
@KylieYYing
@KylieYYing 4 жыл бұрын
:) Happy to help!
@sunnyfreedomfighter
@sunnyfreedomfighter 4 жыл бұрын
one problem i realised. is that i cant seem to import the words from my word file!....i will try to solve problem on my own....if not i will come back defeated and asking for help.....hope you are well!
@KylieYYing
@KylieYYing 4 жыл бұрын
I just came out with a new video for a beginner crash course in Python, so that might help you out :) kzbin.info/www/bejne/fWnRpGV-rdWAZrc
@sunnyfreedomfighter
@sunnyfreedomfighter 4 жыл бұрын
@@KylieYYing thank you. I will check it out later... currently doing night shifts for two weeks. Then I can indulge myself in python. P.s I've checked your website out ...you seem to be a secret agent of some sort!! Literally motivated me to learn roller blading. I hope you are safe and happy! Many thanks ::))
@peterpancakeA
@peterpancakeA 4 жыл бұрын
So cool, i try to improme my english and my code level in the same time . I saw that you studied in France. I'm french do you speak french?
@KylieYYing
@KylieYYing 4 жыл бұрын
un peu haha
@lahocoschimocotaesdesteusj559
@lahocoschimocotaesdesteusj559 3 жыл бұрын
@@KylieYYing hello what's your native language?
@lisali6205
@lisali6205 4 жыл бұрын
Thank you. I like to watch your typing.
@laughing-out-loudhd996
@laughing-out-loudhd996 3 жыл бұрын
Ya luv Python.. if am nt mistaken.. I luv Python too... ! .. post more video .. liking it !
@khawarabbas100
@khawarabbas100 3 жыл бұрын
What is this Coding for. What is its output product.
@NK47k
@NK47k 3 жыл бұрын
now how do I link this with my discord bot?.
@udayy4448
@udayy4448 4 жыл бұрын
LEGEND
@Frazle_
@Frazle_ 4 жыл бұрын
where do you get python?
@KylieYYing
@KylieYYing 4 жыл бұрын
Frazle great question! You can get python online here: www.python.org/downloads/ And then you can download a free text editor such as pycharm, atom, sublime, etc.. (can be found online) Would it help if I made a tutorial on how to get started using python?
@Frazle_
@Frazle_ 4 жыл бұрын
Y Cubed well I was making a game for someone’s website for a degree in tongues but it has to be handed in tomorrow so I don’t think I have time to do it but it would be a good idea for a vid for beginners on python
@Frazle_
@Frazle_ 4 жыл бұрын
Y Cubed good video btw 👍🏻
@KylieYYing
@KylieYYing 4 жыл бұрын
Thank you :) I’m planning on making more coding videos in the future!!
@lahocoschimocotaesdesteusj559
@lahocoschimocotaesdesteusj559 3 жыл бұрын
bruh this is insane, ppl who dont know where to get python are learning this? keep calm Frazle, go calm, slowerrrr
@do_ctor_d476
@do_ctor_d476 4 жыл бұрын
how do you play the game
@KylieYYing
@KylieYYing 4 жыл бұрын
You can run it from terminal on mac or command prompt on windows! Check out my python crash course if you’re interested in learning more
@codewithparth8431
@codewithparth8431 4 жыл бұрын
Great video's
@carllewis6745
@carllewis6745 3 жыл бұрын
Thank you.
@lucian8618
@lucian8618 2 жыл бұрын
I ended in an infinite loop , almost crushed
@udayy4448
@udayy4448 4 жыл бұрын
full code: import random from words import words import string def get_valid_word(words): word = random.choice(words) # randomly chooses something from the list while '-' in word or ' ' in word: word = random.choice(words) return word.upper() def hangman(): word = get_valid_word(words) word_letters = set(word) # letters in the word alphabet = set(string.ascii_uppercase) used_letters = set() # what the user has guessed lives = 6 # getting user input while len(word_letters) > 0 and lives > 0: # letters used # ' '.join(['a', 'b', 'cd']) --> 'a b cd' print('You have', lives, 'lives left and you have used these letters: ', ' '.join(used_letters)) # what current word is (ie W - R D) word_list = [letter if letter in used_letters else '-' for letter in word] print('Current word: ', ' '.join(word_list)) user_letter = input('Guess a letter: ').upper() if user_letter in alphabet - used_letters: used_letters.add(user_letter) if user_letter in word_letters: word_letters.remove(user_letter) print('') else: lives = lives - 1 # takes away a life if wrong print(' Your letter,', user_letter, 'is not in the word.') elif user_letter in used_letters: print(' You have already used that letter. Guess another letter.') else: print(' That is not a valid letter.') # gets here when len(word_letters) == 0 OR when lives == 0 if lives == 0: print('You died, sorry. The word was', word) else: print('YAY! You guessed the word', word, '!!') if name == 'main': hangman()
@lahocoschimocotaesdesteusj559
@lahocoschimocotaesdesteusj559 3 жыл бұрын
i did the same stuff with 60 lines of code LOL
@udayy4448
@udayy4448 3 жыл бұрын
@@lahocoschimocotaesdesteusj559 send
@lahocoschimocotaesdesteusj559
@lahocoschimocotaesdesteusj559 3 жыл бұрын
now its not 60 lines bc i added the little body as levels, and if i show it im scared someone steal it, i just give these steps: 1.Learn list(appending) 2.Learn enumerate now use ur logic and do it
@NSVSTB
@NSVSTB 2 жыл бұрын
Thank you so much. Saved me from constantly getting blank when i run the codes!
@glowria_balla4332
@glowria_balla4332 2 жыл бұрын
ImportError: cannot import name 'words' from 'words' (unknown location) I keep seeing this
@whyisgamaretaken
@whyisgamaretaken 4 жыл бұрын
Subscribe to this guy, he is insane
@ayoubguennane5230
@ayoubguennane5230 5 жыл бұрын
perfect
@KylieYYing
@KylieYYing 5 жыл бұрын
ayoub guennane thanks! Glad you enjoyed it :)
@vortex4109
@vortex4109 2 жыл бұрын
Here's the first part of my code: import random from words import words def get_valid_word(words): word = random.choice(words) # randomly chooses word while "-" in word or " " in word: word = random.choice(words) return word def hangman(): word = get_valid_word(words) word_letters = set(word) # letters in word alphabet = set(str.ascii_uppercase) used_letters = set() # what the user has guessed #getting user input while len(word_letters) > 0: #letters used print("You have already used these letters: ", " ".join(used_letters)) # What current word is ( ie W - R D) word_list = [letter if letter in used_letters else "-" for letter in word] print("Current word: ", " ".join(word_list)) user_letter = input('Guess a letter').upper() if user_letter in alphabet - used_letters: used_letters.add(user_letter) if used_letters in word_letters: word_letters.remove(user_letter) elif user_letter in used_letters: print("You have already guessed that character. Please try again.") else: print("Invalid character. Please try again.") user_input = input('Type something: ') I've tried using it but here's what happens in terminal: Type something: e Type something: e Type something: e Type something: e Type something: e Type something: e Type something: ee Type something: e Type something: e Type something: e Type something: e Type something: e Type something: e Type something: ee Type something: e Type something: e Type something: e Type something: Type something: e Type something: e Type something: e Type something: e Type something: e Type something: e Type something: e Type something: e Type something: e Type something: e Type something: e Type something: e Type something: e Type something: e Type something: Type something: a Type something: a Type something: a Type something: a Type something: dw Type something: dad Type something: Type something: fa Type something: g Type something: Type something: rhgr Type something: grazs Type something: rgsd Type something: drg Type something: grdhjt Type something: htdtgh Type something: drg Type something: [ ] Any help???
How to code Rock Paper Scissors (Beginner Python Tutorial)
8:45
JISOO - ‘꽃(FLOWER)’ M/V
3:05
BLACKPINK
Рет қаралды 137 МЛН
How To Code Hangman In Python | Tutorial For Beginners
16:26
Shaun Halverson
Рет қаралды 51 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 665 М.
3 PYTHON AUTOMATION PROJECTS FOR BEGINNERS
17:00
Internet Made Coder
Рет қаралды 1,7 МЛН
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 417 М.
Python for Beginners - Learn Coding with Python in 1 Hour
1:00:06
Programming with Mosh
Рет қаралды 19 МЛН
5 Python Libraries You Should Know in 2025!
22:30
Keith Galli
Рет қаралды 70 М.
Let's code a HANGMAN GAME in Python! 🕺
25:07
Bro Code
Рет қаралды 21 М.
How to build HANGMAN with Python in 10 MINUTES
9:53
Kite
Рет қаралды 471 М.