keyboard_arrow_left keyboard_arrow_right
Pablo's Project

Hangman Game

About Pablo

My name is Pablo Rodriguez, and I am in 8th Grade. One of my favorite things to do is to study the natural sciences; such as biology, chemistry, and geology. I also enjoy reading both fiction and non-fiction books.

Pablo's project details:

Hangman is a popular game that is played in many places around the world. For my project, I decided to make this game playable through Python. The goal of the game is to guess a mystery word off of guessing letters correctly one at a time.
1. Click on the “RUN” button below to run the program.
2. This is very interesting. And I hope you all would surely enjoy and like it.
Click on
play icon below to run the code and see the magic unfolding.

import random
print(" ")
print("Welcome to Hangman!")
words = [["m","o","u","s","e"],["p","l","a","n","e"],["p","h","o","n","e"],["p","a","r","t","y"],
rounds = int(input("How many rounds do you want to play?(Enter a number): "))
r = 0
while r < rounds:
    fails = 0
    a = 0
    spots = ["_", "_", "_", "_", "_"]
    currentword = random.choice(words)
    print("Round", r + 1)
    while a < 5 and fails < 15:
        if a == 0 and fails == 0:
            guess = str(input("""
_ _ _ _ _

    Guess any letter: """))
            guess = str(input("Guess another letter: "))
        for i in range(0,5):
            if guess in spots[i]:
                print("You already guessed", guess)  #in case the user selects again a succesful letter
            if guess in currentword[i] and guess not in spots[i]:
                a += 1
        if guess not in currentword:
            fails += 1
        if fails == 15:
            print("""You lose. Better luck next time
You guessed the wrong letter 15 times
The correct answer was""", currentword[0]+currentword[1]+currentword[2]+currentword[3]+currentword[4]+'.')
    r += 1
print("Thanks for Playing!!!")
Name: Pablo Rodriguez
Grade: 8
  My son loves his Python course. He has now become very interested in coding and he has learned a lot. He also has a great instructor. I would definitely recommend the course.
Parents of Pablo Rodriguez
Be the Next Creator like :