-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest1
More file actions
67 lines (43 loc) · 1.5 KB
/
test1
File metadata and controls
67 lines (43 loc) · 1.5 KB
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
import random
def play():
print(f"\n length of the word is {length_key}")
while True:
print("\n WELCOME TO HANGMAN GAME----")
print('''
_______
| |
| O
| \|/
| |
___|___ / \
''')
keywords = {
'animals' : [['l','i','o','n'],['f','o','x'],['e','l','e','p','h','a','n','t']] ,
'fruits' : [['a','p','p','l','e'],['p','i','n','e','a','p','p','l','e'],['w','a','t','e','r','m','e','l','o','n']]
}
key, value = random.choice(list(keywords.items()))
j = random.choice(range(0,2))
print(f"\n The topic of hangman is {key} and {value[j]}" )
length_key = len(value[j])
play()
word = input("\n Guess the letter: ")
inputstring = "_ " * length_key
print(inputstring)
i = 0
while i < length_key :
inputstring = word if value[j][i] == word else "_ "
print(inputstring , end = " ")
i += 1
i = 0
while i < length_key :
if value[j][i] == word:
print("\n value is correct")
break
else:
while i == length_key - 1:
if value[j][i] == word:
print("\n value is correct")
else:
print("\n Opps!!! value is incorrect")
break
i += 1