-
Notifications
You must be signed in to change notification settings - Fork 2
/
hangman.py
executable file
·76 lines (70 loc) · 1.73 KB
/
hangman.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python3
__author__ = "Jugal Kishore & Akash Shiva"
__version__ = "1.0"
import random
print("///Hangman Game///")
print("")
print(" ~ You have 5 attempts to guess it right")
attempt = 5
win = 0
total = {
"Flower": [
"rose",
"jasmine",
"lilly",
"tulip",
"snowdrops",
"lotus",
"cherry",
"sunflower",
],
"Animal": ["dog", "cat", "elephant", "horse", "lion", "tiger", "cheetah", "bear", ],
"Computer Part": [
"mouse",
"keyoard",
"monitor",
"speaker",
"processor",
"motherboard",
"pendrive",
],
"Body Part": [
"fingers",
"toe",
"leg",
"hairs",
"eyes",
"nose",
"ears",
"lips",
"hips",
"mouth",
],
}
random_list = random.choice(list(total.keys()))
random_word = random.choice(total[random_list])
print("Hint: It's", random_list)
print("Picking Random word... Done!")
while attempt >= 1:
print("")
if attempt == 4:
print("Hint 1: First letter is --->", random_word[0])
elif attempt == 3:
print("Hint 2: Second letter is --->", random_word[1])
print("Enter {0} Name:".format(random_list))
input_word = input().lower().replace(" ", "")
if input_word == random_word:
win += 1
break
else:
attempt -= 1
print("")
if attempt != 0:
print("Wrong Guess! Attempts Remaining:", attempt)
if win > 0:
print("")
print("Indeed the Correct Answer is:", input_word)
else:
print("All attempts are over, You are a looser :(")
print("\nCreated by Jugal Kishore & Akash Shiva -- 2020")
# Run it online at https://python.jugalkishore.repl.run/