-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHangman.py
43 lines (36 loc) · 887 Bytes
/
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
import random
WORDLIST = [""]
updatedWord = ""
secret = ""
letter = ""
def initialize():
global updatedWord
global SECRET
WORDLIST = ['one','two','three','four','five','six','seven','eight','nine','ten']
SECRET = random.choice(WORDLIST)
updatedWord = [('_'*len(SECRET))]
print(updatedWord)
print SECRET
def getLetter():
global letter
letter = str(raw_input('ENTER YOUR GUESS: '))
print ('YOUR GUESS: ' + letter)
def fillLetter():
pos = SECRET.find(letter)
updatedWord[pos] = letter
def ifWon():
if updatedWord == SECRET:
print ('You Won!')
else:
getLetter()
def main():
initialize()
getLetter()
def test():
if (letter in secret):
pos = secret.find(letter)
updatedWord[pos] = letter
print updatedWord.join()
ifWon()
else:
getLetter()