-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code
82 lines (73 loc) · 2.15 KB
/
Code
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
77
78
79
80
81
82
import random
import time
# introduction to the game
print ("let/'s play hangman")
print ('''_______
|/ |
| O
| \_|_/
| |
| / \\
| / \\
____|____
\n''')
# Game instructions:
print('''You get 7 lives to guess the letters in the word.
If you guess incorrectly more of the hangman will appear and you lose a life.
When you have used all of your 7 lives, the man will have hung and you will have lost.
If you guess a correct letter, it will be shown and if you guess the word without using the 7 turns, you win!''')
#credits
print("made by Total Aviation")
print("version 1.0 ")
input("\nPress enter to start the game")
print("Hangman words are based on computer science and Youtube Enjoy ")
# List of words
words = ['variable','string','integer','selection', 'iteration','loop','operator','computerscience']
words1 = ['subscribe','dislikes','likes','Youtube', 'views','upload','Tags','contentcreator']
#Randomly choose a word from the list
secret = random.choice(words1)
secret = random.choice(words)
guessed = ''
turns = 7
while turns > 0:
missed = 0
print()
for letter in secret:
if letter in guessed:
print (letter,end=' ')
else:
print ('_',end=' ')
missed = missed + 1
if missed == 0:
print ('\n\nYou win!')
break
guess = input('\n\nGuess a letter: ')
guessed = guessed + guess
if guess not in secret:
turns = turns - 1
missed = missed + 1
print ('Nope.')
print (turns, 'more turns')
if turns < 7:
print(' _______')
print(' |/ |')
if turns < 6:
print(' | O')
if turns < 5:
print(' | \_|_/')
if turns < 4:
print(' | |')
if turns < 3:
print(' | / \\')
if turns < 2:
print(' | / \\')
if turns == 0:
print(' __|____')
print ('\nThe answer is', secret)
print("https://github.com/TotalAviationJmyt")
print("version 1.0 ")
play_again = input("Do you want to restart? Y/N")
if play_again == "Y":
exec(open("./Hangman-TA.py").read())
else:
exit()