Python Hangman game | How to Build hangman | Python Beginners Project | 2020

Published: 05 September 2020
on channel: Nilesh Technology
793
18

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

import random
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]
.

Blogging Site : https://learnwithnileshborate.blogspo...
.
please drop a mail or type your questions in the comment section.
Mail ID : [email protected]
Website : nileshtechnology.in