This repository has been archived by the owner on Oct 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
65 lines (58 loc) · 1.74 KB
/
main.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
import time
import os
'''https://docs.python.org/3/library/os.html && https://www.w3resource.com/python-exercises/python-basic-exercise-99.php (clear terminal)'''
import random
#Procedures
def randomWord(words):
chosenWord = words[random.randint(0, len(words)-1)]
print("DEBUG: the word chosen is " + chosenWord)
return chosenWord
def wipeScreen():
os.system('cls')
def indexWord(wordChosen):
index = []
for letter in wordChosen:
index.append(letter)
return index
def letterCheck(letter, wordIndex):
for i in range(0, len(wordIndex)-1):
print("Test")
print(" | ")
print(" | ")
print(" () ")
print(" /|\ ")
print(" /\ ")
#Variables
wordList = ["house", "design", "export", "market", "resort", "winner"]
wordLetterIndex = [""]
numOfGuesses = 0
wrongGuesses = 0
chedkAn = 0
name = ""
gameSession = True
blankAnswer = "_____"
newAnswer = ""
tempAnswer = ""
#main
name = input("What is your name?\n")
print("Welcome to hangman " + name + "!" )
print("Hangman is where you guess the letter by typing it in")
print("Becareful though as it slowly creates a stickfigure when guessing incorrectly!")
wordChose = randomWord(wordList)
print(wordChose)
wordLetterIndex = indexWord(wordChose)
'''print("Debug: Index of the chosen word is ")
for x in wordLetterIndex:
print(x)'''
while (gameSession == True):
userInput = input("What letter what you like to type in? (Only ONE!)")
for i in range(0, len(wordLetterIndex)-1):
if (userInput == i):
'''checkAn = checkAn+1'''
print("DEBUG: found a match")
newAnswer = newAnswer + userInput
else:
newAnswer = newAnswer + "_"
tempAnswer = newAnswer
print("DEBUG: Completed Loop and displaying word " + newAnswer)
#print(checkAn)