Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e9e057f

Browse files
Merge pull request avinashkranjan#278 from Ayush7614/master
Hangman Game
2 parents 8fae665 + e646005 commit e9e057f

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

‎Hangman Game/Output.jpeg‎

52.4 KB
Loading[フレーム]

‎Hangman Game/README.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Hangman Game
2+
3+
Create a List of secret words and randomly pick a word. Now represent each word as _ and give user chances to guess the word if the user guesses the word right then replace _ with the word.
4+
5+
## Setup Instruction
6+
7+
first install time package in your system open your terminal and write `pip install time` this will install time module in your system and random module is already install in python by itself so don't waste your time. Now make file `program.py` or whatever your choice and write program from program.py file and run it.
8+
9+
Make sure you have installed the **necessary packages** listed in **`requirements.txt`**, then simply run **`program.py`**.
10+
11+
# Screenshots
12+
[Output](https://github.com/Ayush7614/Amazing-Python-Scripts/blob/master/Hangman%20Game/Output.jpeg)

‎Hangman Game/program.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import time
2+
import random
3+
name = input("What is your name? ")
4+
print ("Hello, " + name, "Time to play hangman!")
5+
time.sleep(1)
6+
print ("Start guessing...\n")
7+
time.sleep(0.5)
8+
## A List Of Secret Words
9+
words = ['python','programming','treasure','creative','medium','horror']
10+
word = random.choice(words)
11+
guesses = ''
12+
turns = 5
13+
while turns > 0:
14+
failed = 0
15+
for char in word:
16+
if char in guesses:
17+
print (char,end="")
18+
else:
19+
print ("_",end=""),
20+
failed += 1
21+
if failed == 0:
22+
print ("\nYou won")
23+
break
24+
guess = input("\nguess a character:")
25+
guesses += guess
26+
if guess not in word:
27+
turns -= 1
28+
print("\nWrong")
29+
print("\nYou have", + turns, 'more guesses')
30+
if turns == 0:
31+
print ("\nYou Lose")

‎Hangman Game/requirements.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
random
2+
time
52.4 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /