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

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 เม.ย. 2023
  • In this Python Lecture we are going to build Hangman Game . We will discuss the Complete Code line-by-line. The game will allow for user input, and will also output a visual of the hangman alongside the word that’s being guessed.
    Best Python Tutorials for Beginners: • Python - Basic to Advance
    *********************************************
    Connect & Contact Me:
    My Second Channel Link: bit.ly/354n7C7
    Facebook: / jennys-lectures-csit-n...
    Quora: www.quora.com/profile/Jayanti...
    Instagram: / jayantikhatrilamba
    Twitter: / khatrijenny
    *******************************************
    More Playlists:
    Programming in C Tutorials: • Programming in C
    C++ Tutorials for beginners: • Lec 1: How to Install ...
    Placement Series: • Placements Series
    Data Structures and Algorithms: https: • Data Structures and Al...
    Design and Analysis of Algorithms(DAA): • Design and Analysis of...
    Dynamic Programming: • Dynamic Programming
    Operating Systems tutorials: // • Operating Systems
    DBMS Tutorials: • DBMS (Database Managem...
    #pythonprojects #pythonforbeginners #python #jennyslectures #pythonprogramming #hangman

ความคิดเห็น • 94

  • @lifebyvikk6751
    @lifebyvikk6751 8 หลายเดือนก่อน +3

    I just like how you break complex problems into small problems in order to have them solved,, the way you pause and think and write code is very helpful for someone who wants to really learn how to solve programming problems not only in python but any language for that matter! Thank you Jenny!

  • @BCKSPCEMusic
    @BCKSPCEMusic ปีที่แล้ว +4

    Well this was really crazy in a good way, i don't know if this channel is for explaining kids but i am 24years old & enjoying it

  • @Arceus948
    @Arceus948 ปีที่แล้ว +28

    Mam pls start machine learning Playlist, i beg u 😭😭🙏🏻🙏🏻🙏🏻

    • @santhoshk2722
      @santhoshk2722 ปีที่แล้ว +3

      I'm also waiting for that

    • @jyoth2009
      @jyoth2009 ปีที่แล้ว +2

      Yes mam

    • @ShivamSingh-ez5dc
      @ShivamSingh-ez5dc 9 หลายเดือนก่อน

      Yes

    • @lifebyvikk6751
      @lifebyvikk6751 8 หลายเดือนก่อน

      I think she has already done a superb job teaching python, I would probably master python well first if I were you

    • @Arceus948
      @Arceus948 8 หลายเดือนก่อน +1

      @@lifebyvikk6751 i have already mastered python bro, now i want to learn ML

  • @tmurari9452
    @tmurari9452 ปีที่แล้ว +6

    Mam please tell how to draw this Hangman pictures

  • @shivateja3123
    @shivateja3123 ปีที่แล้ว

    just subscribed
    and started watching

  • @subratkumarsahoo1946
    @subratkumarsahoo1946 5 หลายเดือนก่อน

    waah didi waaah..waah didi waah...what an explanation?

  • @amitkmpbtup
    @amitkmpbtup ปีที่แล้ว +3

    IT DOESNT WORK WHEN U DO THE HANGMAN STGES IT IS SHOWING OUT OF INDEX WHEN I RUN IT PLS HELP

  • @user-em8qb4gp8y
    @user-em8qb4gp8y ปีที่แล้ว +1

    In the program of hangman game you have not defined lives. Your program is not showing name error for lives but mine is showing name error. please clear it mam

  • @TSHILIDZI_MUNYAI
    @TSHILIDZI_MUNYAI 10 หลายเดือนก่อน +1

    How to u code the figure? The hangman stages that u just imported

  • @systembreaker4864
    @systembreaker4864 11 หลายเดือนก่อน

    Mam this has one problem that is if we enter correct letter again in the input it will not take lives it's like we can run this continuously until the whole list of "_" these characters is replaced with letters

  • @nityamittal6759
    @nityamittal6759 ปีที่แล้ว +2

    Mam can you make a playlist on asymptotic notation pls😃😃😃

  • @omkarmurala2084
    @omkarmurala2084 ปีที่แล้ว

    Like u said we can make this hangman game in multiple ways can u please elaborate so that we can understand

  • @Chandu_SKY
    @Chandu_SKY 6 หลายเดือนก่อน +1

    Hangman module not found error mam

  • @sachinwankhede3346
    @sachinwankhede3346 4 หลายเดือนก่อน +2

    8:48 match expressions😊

  • @glps369
    @glps369 11 หลายเดือนก่อน

    Thank You So Much

  • @abhileswar
    @abhileswar 7 หลายเดือนก่อน

    type error = showing cannot concatenate list (not "str") to list ,
    in line display = display + '_' ,
    mam can u explain this problem

  • @ngsscofficial
    @ngsscofficial 21 วันที่ผ่านมา

    THANK YOU SO MUCH MAAM

  • @Khan_aamir.
    @Khan_aamir. 3 หลายเดือนก่อน

    Thank you so much mam😊😊😊😊

  • @yogendrathakur8053
    @yogendrathakur8053 ปีที่แล้ว

    Very good 🎉😂

  • @Bodigajohnygoud
    @Bodigajohnygoud 9 หลายเดือนก่อน

    mam what if a user enter's a correct word repeatedly??

  • @Shashank1703
    @Shashank1703 ปีที่แล้ว

    Mam Do one video on Java Programming Basics

  • @lakshmivaddi4395
    @lakshmivaddi4395 2 หลายเดือนก่อน

    hello mam,i have a doubt..suppose one word has two or three same letters like example swiss.if we guess a lettter s from word it should placed only one s.. right ?but in our program at a time three 3 S are placed in display..only one letter should be placed by one chance.please clarify my doubt mam

  • @-SakuraNoHana-
    @-SakuraNoHana- 2 หลายเดือนก่อน +1

    Hello ma'am,
    Can you please make a video on python import time?
    I would really appreciate it.
    Thank you!

  • @RishabhChatterjee-fg2gz
    @RishabhChatterjee-fg2gz 11 หลายเดือนก่อน +1

    Ma'am I'm currently studying in 1st year of diploma in computer science and technology and my dream is to give gate exam and python is my favorite language and I don't want to do any job , I want to be a data scientist professional and want to research about data science field like machine learning, deep learning, artificial intelligence, etc..
    I have a question
    what is big data?
    and I want to say you to make this course as a professional python developer

  • @bestvideos9088
    @bestvideos9088 5 หลายเดือนก่อน +1

    But how you make hangman_stages?

  • @shahiddar9852
    @shahiddar9852 ปีที่แล้ว

    Mam can you please send me the details how to make a website
    I want to make a website

  • @g.viswnathreddy1869
    @g.viswnathreddy1869 ปีที่แล้ว +1

    Mam ,provide notes in description please 😊😊

  • @burragallaneeraj8136
    @burragallaneeraj8136 ปีที่แล้ว +1

    Please provide code in the description

  • @utkarsh_aa786
    @utkarsh_aa786 ปีที่แล้ว

    Maam I am just pass class 12th with( PCM) but ab Samajh nhi aa rha Iska kya 🤔kru?

  • @ObulshettySrikari
    @ObulshettySrikari 9 หลายเดือนก่อน +2

    Mam instead of making an empty list can we write
    for i in chosen_list:
    print("_", end=" ")
    Will we get blanks mam??

    • @user-wb2kf5mt1u
      @user-wb2kf5mt1u 8 หลายเดือนก่อน +2

      display = ['_']*len(chosen_word) #This will do your job

  • @ruhulameem1397
    @ruhulameem1397 ปีที่แล้ว +6

    Hello mam
    mam please make video on numpy, matplotlib, and pandas library of python because i am preparing as a data analytics and these library is necessary for being data analytics ur concept and way of teaching is very elegant and fabulous i learn data structures from your tutorial and suggest my junior to watch your video of DSA please mam make video on these library tl
    thank you

  • @akhil2721
    @akhil2721 ปีที่แล้ว +1

    Mam its a humble request please start c++, I have c++ in my 3 rd sem and currently i am in 2nd sem , so i will need it in 3rd sem .

  • @mzxrex9381
    @mzxrex9381 10 หลายเดือนก่อน +1

    Mam where should i run this code
    In jupyter notebook or vs code

    • @Praveen_C11
      @Praveen_C11 หลายเดือนก่อน +1

      Vs is better

  • @-NChandana-pm9hb
    @-NChandana-pm9hb 8 หลายเดือนก่อน +1

    No module named hangman_stages

  • @yogalakshmipabbisetty5966
    @yogalakshmipabbisetty5966 ปีที่แล้ว +2

    Mam could u plz start java

  • @kirankumar-pv1yy
    @kirankumar-pv1yy ปีที่แล้ว +2

    Mam please Start Java Classes

  • @kalyanitamanampudi
    @kalyanitamanampudi 4 หลายเดือนก่อน

    Plzz mam start the classes of data science alsoo

  • @NARENDRAPAGOTI
    @NARENDRAPAGOTI ปีที่แล้ว

    mam please teach us java too

  • @SriRam-in2zv
    @SriRam-in2zv 3 หลายเดือนก่อน

    In Python 3.12, it is showing the hangman_stages function is not compatible.
    Please let me know if there is any other function which can be used in 3.12

    • @georgevincent93
      @georgevincent93 หลายเดือนก่อน

      it is not an inbuild function it is another python file she created naming "hangman_stages"

  • @VenkateshAnnabathina
    @VenkateshAnnabathina 20 วันที่ผ่านมา

    #need machine learning playlist

  • @marieswaran8124
    @marieswaran8124 11 หลายเดือนก่อน

    Hi Madam,
    I have doubt in this session, How did you add display variable(list data type) with '_' string. Because those are different data type. Can you provide the answer for this doubt.

    • @rameshamma6497
      @rameshamma6497 10 หลายเดือนก่อน

      The list contains an empty string, we are just concatenation with another string.

  • @ChildhoodForever1808
    @ChildhoodForever1808 ปีที่แล้ว +2

    Ma'am I am currently in 1st year of btech and I want to prepare for gate. When do you think I should start preparing for it please tell me 🙏

    • @rauhan_sheikh
      @rauhan_sheikh 11 หลายเดือนก่อน

      for the 1st 2-3 years focus on learning and building projects and also do internship in the 3rd year and based on that decide if you have to or want to do gate or not. if you decide you have better opportunities already because you have built good projects and have proof of work then leave it else if you still want to pursue gate then start. 1 and half year of dedicated preparation is good enough for gate.

  • @rahim...writeschannel2.3k14
    @rahim...writeschannel2.3k14 ปีที่แล้ว

    💞👍👍👍

  • @munamarziya2546
    @munamarziya2546 ปีที่แล้ว +4

    Ma'am you better start your own college,,,,,,i am from non cs branch,,,,,you will get me and my friends as students for sure 🥺

  • @mattapallichandrashekar8947
    @mattapallichandrashekar8947 ปีที่แล้ว

    Mam please start Java play list

  • @everythingwithanirudha
    @everythingwithanirudha ปีที่แล้ว

    mam quality to improve karo, like camera or iphone, or may be the compression is bit high

  • @bandikomalkumar8066
    @bandikomalkumar8066 ปีที่แล้ว +1

    What is meant by "Scratch file" which is displayed at top left corner of "Pycharm" application under pythonProject~New~Scratch File. Please 🥺 mam!

    • @Praveen_C11
      @Praveen_C11 หลายเดือนก่อน +1

      Scratch file is just like any other file types like python file or html file or text file. Scratch is the most basic programming language one can learn, usually taught to kids in school. Pycharm has Scratch file as it's default file like how notepad has text file as default, u can change it to python by saving it with .py extension or as text file with .txt extension

  • @jyoth2009
    @jyoth2009 ปีที่แล้ว

    Mam uploaded more and more python videos please

  • @sharifullahsalarzai
    @sharifullahsalarzai ปีที่แล้ว

    Mam please complete c++ videos

  • @braveheart3176RTY
    @braveheart3176RTY 3 หลายเดือนก่อน

    hello im rhey from philippines

  • @tech_gaming889
    @tech_gaming889 ปีที่แล้ว

    Mam we want emcet online classes

  • @Lucky_truth
    @Lucky_truth 9 หลายเดือนก่อน +8

    import random
    print("WELCOME TO HANGMAN")
    heart=6
    won=False
    list1= ["lamp", "chair", "book", "spoon", "tree", "hat", "bike", "door", "pen", "cup", "shoe", "clock", "ball", "table", "sun", "moon", "flower", "bridge", "cloud", "pillow"]
    # random words
    word=random.choice(list1)#choose a random word from the list
    word=list(word)#make it in to list again
    output = ["_"] * len(word)
    print(output)
    while heart:
    guess=input("Guess a letter")
    for i in range(len(word)):
    if(guess==word[i]):
    output[i]=guess
    print(output)
    if(output==word):
    won=True
    print("you won!")
    if (guess not in word):
    heart -= 1
    print(f"You have {heart} heart left")
    if(won==True):
    break
    if(heart==0):
    print(f"The word is {word}")

  • @selamawitbirhanu7298
    @selamawitbirhanu7298 8 หลายเดือนก่อน

    thanks mam if you can please send us your source code Thank you

  • @vaibhavpatharkar6794
    @vaibhavpatharkar6794 ปีที่แล้ว +1

    Madam iff possible pl use hindi or mixed lang

  • @narendrakota890
    @narendrakota890 ปีที่แล้ว

    Third👍

  • @kirugaming6603
    @kirugaming6603 ปีที่แล้ว

    Mam vs code me karo code ko .......

  • @abishakthd6884
    @abishakthd6884 ปีที่แล้ว +1

    I love you 😍 💗 mam

  • @gangabankala7745
    @gangabankala7745 ปีที่แล้ว

    Madam please make sure send notes in description madam please it's my humble request 😢😢😢

  • @ALIENGOATMESSI
    @ALIENGOATMESSI ปีที่แล้ว +2

    here for beauty

  • @RouMuanNgaihte
    @RouMuanNgaihte ปีที่แล้ว

    First

  • @lovekushrajput442
    @lovekushrajput442 ปีที่แล้ว

    Third😄😄😄😂

  • @abishakthd6884
    @abishakthd6884 ปีที่แล้ว +2

    Mam u r so very beautiful

  • @nithinvasamsetti
    @nithinvasamsetti หลายเดือนก่อน

    🥵🥵🥵

  • @atmasgamingyt3168
    @atmasgamingyt3168 ปีที่แล้ว

    Second

  • @wownoob-hp9pp
    @wownoob-hp9pp 7 หลายเดือนก่อน

    come to pakistan.

  • @adhitya001
    @adhitya001 ปีที่แล้ว

    Zero

  • @shaniskshanigamer4085
    @shaniskshanigamer4085 ปีที่แล้ว

    Hlo mam

  • @coding_with_bf
    @coding_with_bf ปีที่แล้ว

    Mam 😢

  • @muneebbolo
    @muneebbolo 5 หลายเดือนก่อน +3

    Here's what each part of the code does:
    1. **Imports and Initial Setup**

    import random
    import hangman_stages
    import words_file
    ```
    These lines import the necessary modules for the game. `random` is a built-in Python module for generating random numbers. `hangman_stages` and `words_file` are custom modules that contain the hangman stages and the word list, respectively.
    2. **Game Variables**

    lives=6
    chosen_word=random.choice(words_file.words)
    print(chosen_word)
    ```
    Here, the variable `lives` is set to 6, representing the number of incorrect guesses the player is allowed. `chosen_word` is a randomly selected word from the word list in `words_file`. This word is what the player has to guess.
    3. **Display Setup**

    display=[]
    for i in range(len(chosen_word)): #0 1 2 3 4
    display +='_'
    print(display)
    ```
    This code creates a list `display` that is used to show the player's progress in guessing the word. It starts as a list of underscores, with one underscore for each letter in `chosen_word`.
    4. **Game Loop**

    while not game_over:
    letter_guess = input('Guess the letter ').lower() # r
    for position in range(len(chosen_word)):
    letter=chosen_word[position]
    if letter==letter_guess:
    display[position] = letter_guess
    print(display)
    ```
    This is the main game loop. The player is asked to guess a letter, which is then checked against each letter in `chosen_word`. If the guessed letter is in the word, the corresponding underscore in `display` is replaced with the letter.
    5. **Lives and Game Over Conditions**

    if letter_guess not in chosen_word:
    lives -= 1
    if lives == 0:
    game_over = True
    print('Game Over, You Lose! ')
    if '_' not in display:
    game_over = True
    print('You win!! ')
    print(hangman_stages.stages[lives])
    ```
    If the guessed letter is not in the word, the player loses a life. If all lives are lost (`lives == 0`), the game ends and the player loses. If there are no more underscores in `display`, meaning the player has guessed all the letters, the game also ends and the player wins. After each guess, the current hangman stage is printed based on the number of remaining lives.

  • @shivaojha6760
    @shivaojha6760 ปีที่แล้ว +1

    Mam I am a student of MITS Gwalior please help me python language

    • @Arceus948
      @Arceus948 ปีที่แล้ว +1

      Python language is non living thing bruh, how it can help u 😢😢😭😭

    • @maradanavivek2386
      @maradanavivek2386 ปีที่แล้ว

      ​@@Arceus948😂😂😂😂

  • @ravana194
    @ravana194 ปีที่แล้ว +1

    Mam will you marry me 😊😊

  • @Rayray-cd3sz
    @Rayray-cd3sz ปีที่แล้ว +2

    # without figure and alternatives which are commented
    import random
    list_1 = ["apple", "banana", "cherry", "avocado", "kiwi", "jackfruit"]
    task_1 = random.choice(list_1)
    # list_2 = []
    print("Guess name of the fruit ! ")
    #for dash in task_1:
    #list_2.append("_")
    # list_2 += "_"
    hidden_word = ["_"] * len(task_1)
    # print(hidden_word) is a list of strings
    print("".join(hidden_word)) # strings joined
    # print(hidden_word) remains a list of strings
    attempts = 0
    no_of_guesses = 6
    guessed_letter = set()
    while "_" in hidden_word and attempts < no_of_guesses:
    guess = input("Guess a letter of the word: ")
    if len(guess) != 1:
    print("Enter a single letter at a time! ")
    elif guess in guessed_letter:
    print("Already guessed, life reduced !")
    attempts += 1
    print(f"{no_of_guesses - attempts} lives remaining")
    else:
    guessed_letter.add(guess)
    if guess in task_1:
    for i in range(len(task_1)):
    # for i, letter in enumerate(task_1):
    if task_1[i] == guess:
    # if letter == guess and hidden_word[i] == "_":
    hidden_word[i] = guess
    # print(hidden_word)
    print("".join(hidden_word))
    else:
    attempts += 1
    print(f"You have {no_of_guesses - attempts} guess left.")
    if "_" not in hidden_word:
    print("Congratulation, you have guessed the word")
    else:
    print(f"Your chances are over, the correct word is {task_1}")

  • @georgevincent93
    @georgevincent93 หลายเดือนก่อน +1

    import random
    fruits = ["apple", "banana", "orange", "grape", "kiwi", "strawberry", "watermelon", "pineapple", "blueberry", "mango", "pear", "peach", "plum", "cherry", "raspberry", "blackberry", "lemon", "lime", "coconut", "pomegranate", "apricot", "fig", "nectarine", "cranberry", "grapefruit", "tangerine", "lychee", "dragonfruit", "guava", "passionfruit", "melon", "persimmon", "kiwifruit", "cantaloupe", "honeydew", "date", "papaya", "jackfruit", "elderberry", "starfruit", "rhubarb", "boysenberry", "carambola", "kumquat", "soursop", "ackee", "breadfruit", "durian", "longan", "tamarind", "mulberry", "plantain", "quince", "soursop", "uglifruit"]
    guess=random.choice(fruits)
    length=len(guess)
    list1=[]
    for i in range(length):
    list1.append("-")
    print(list1)
    flag=0
    n=0
    while('-' in list1 and n!=6):
    x=input("guess the alphabet ")
    for i in range(length):
    if guess[i]==x:
    flag=1
    list1[i]=x
    if(flag==1):
    print(list1)
    print("correct")
    if(flag==0):
    n+=1
    print(list1)
    print("incorrect")
    print(f"you lose {n} life")
    flag=0
    if '-' in list1:
    print(f"the correct answer was {guess}")
    print("
    you lose the game")
    else:
    print("
    you win the game")