This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time,os | |
stickmen = [ | |
"\ | |
|------\n\ | |
| O\n\ | |
| ---|---\n\ | |
| / \\ \n\ | |
| / \\ \n\ | |
|_____", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
#Global variables and lists to be used throughout my program. | |
wordsList = ["dog","cat","mouse","hyena"] | |
usedWords = [] | |
lives = 6 | |
stickmen = [ | |
"\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getALetter(): | |
global lives | |
global usedLetters | |
letter = input("please enter a letter") | |
if not len(letter) == 1: #Have they entered only 1 character? | |
mainScreen() | |
elif not letter.isalpha(): #Is that character a letter? | |
mainScreen() | |
elif in usedLetters: # Have they already guessed that letter? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os,random | |
#Global variables and lists to be used throughout my program. | |
wordsList = ["dog","cat","mouse","hyena"] | |
usedLetters = [] | |
chosenWord = random.choice(wordsList) | |
lives = 6 | |
stickmen = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def showUsedLetters(): | |
print(" ".join(usedLetters)) #Join up the letters in the usedLetters list | |
#into one long string and print it! Easy :-) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def drawTheWord(): | |
word = [] #Create a temporary list to add either letters or an underscore | |
for letter in chosenWord: | |
if letter in usedLetters: | |
word.append(letter) | |
else: | |
word.append("_") | |
print(" ".join(word)) #Combine the letters and underscores and print them out. | |
# The string.join(list) method is easy to use and powerful! :-) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def checkWinLose(): | |
global lives #These variables need to global so that they save outside of the function | |
global chosenWord | |
global usedLetters | |
if lives == 0: #If you have no lives the you have lost! | |
os.system('clear') | |
print("\n\nYou lose!!!!!") | |
input("\n\nPress enter to start again") | |
chosenWord = random.choice(wordsList)#After here reset lives,empty usedLetters and pick a new word. | |
lives = 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mainScreen(): | |
checkWinLose() # Add me to the mainScreen function! | |
#rest of function here.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stickman = "\ | |
|------\n\ | |
| O\n\ | |
| ---|---\n\ | |
| / \\ \n\ | |
| / \\ \n\ | |
|_____" | |
print(stickman) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def drawStickMan(): | |
print(stickmen[lives]) |