end = "No" mistakes = 0 #Board creator -------------------------------------------------------------------------------------------------------------------------- def board0(): print("") print("") print("") print("") print("") print("") print("") print("") print("") def board1(): print("") print("") print("") print("") print("") print("") print("") print("") print("________") def board2(): print("") print(" | ") print(" | ") print(" | ") print(" | ") print(" | ") print(" |") print(" |") print("_|______") def board3(): print("__________") print(" |/ ") print(" | ") print(" | ") print(" | ") print(" | ") print(" |") print(" |") print("_|______") def board4(): print("__________") print(" |/ |") print(" | ") print(" | ") print(" | ") print(" | ") print(" |") print(" |") print("_|______") def board5(): print("__________") print(" |/ |") print(" | 0") print(" | ") print(" | ") print(" | ") print(" |") print(" |") print("_|______") def board6(): print("__________") print(" |/ |") print(" | 0") print(" | |") print(" | |") print(" | ") print(" |") print(" |") print("_|______") def board7(): print("__________") print(" |/ |") print(" | 0") print(" | --|") print(" | |") print(" | ") print(" |") print(" |") print("_|______") def board8(): print("__________") print(" |/ |") print(" | 0") print(" | --|--") print(" | |") print(" | ") print(" |") print(" |") print("_|______") def board9(): print("__________") print(" |/ |") print(" | 0") print(" | --|--") print(" | |") print(" | / ") print(" |") print(" |") print("_|______") def board10(): print("__________") print(" |/ |") print(" | 0") print(" | --|--") print(" | |") print(" | / \ ") print(" |") print(" |") print("_|______") #Lettermasker -------------------------------------------------------------------------------------------------------------------------- ##import random ##import sys ###An array is needed to run this otherwise it won't get the right letters ##word = ["a", "n", "d"] ## ###These are the values that choose whether the function hides the letter or not ###They are just examples right now so make something change them as needed ##rightletter1 = "no" ##rightletter2 = "yes" ##rightletter3 = "no" ## ###put the array name in the brackets on the line below ##def lettermask(word): ## if rightletter1 == "no": ## letter1 = str("*") ## else: ## letter1 = str(word[0]) ## if rightletter2 == "no": ## letter2 = str("*") ## else: ## letter2 = str(word[1]) ## if rightletter3 == "no": ## letter3 = str("*") ## else: ## letter3 = str(word[2]) ## ## print (str(letter1) + str(letter2) + str(letter3)) ## ##lettermask(word) def word(): import random word = [["a","n","d"], ["e","l","s","e"], ["w","h","i","l","e"], ["f","o","r"], ["l","o","l"], ["f","l","o","o","r"], ["r","o","o","f"], ["a","s","s"]] random_index = random.randint(0,len(word)) print (word[random_index]) return(word[random_index]) def printWord(theWord,letterGuess): arrayLength = len(theWord) for x in range (0, len(theWord)): if theWord[x] == letterGuess: print(letterGuess) else: print(" _ ") def isCorrect(theWord,letterGuess): arrayLength = len(theWord) for x in range (0, len(theWord)): if theWord[x] == letterGuess: return("Win") return("loose") #Letterchecker -------------------------------------------------------------------------------------------------------------------------- def printBoard(fubar): if fubar == 0: board0() if fubar == 1: board1() if fubar == 2: board2() if fubar == 3: board3() if fubar == 4: board4() if fubar == 5: board5() if fubar == 6: board6() if fubar == 7: board7() if fubar == 8: board8() if fubar == 9: board9() if fubar == 10: board10() #Win Lose Checker -------------------------------------------------------------------------------------------------------------------------- def checkWin (totalLetters, correctLetters, wrongGuesses): if wrongGuesses > 9: return("loss") if correctLetters == totalLetters: return("won") if correctLetters < totalLetters: return("keep playing") #endGame module -------------------------------------------------------------------------------------------------------------------------- def endGame(): global end end = "yes" if end == "yes": print("End of Game") randomWord = word() while end == "No": printBoard(mistakes) guess = input("Enter a letter:") x = isCorrect(randomWord,guess) if x == "Win": printWord(randomWord,guess) elif x == "loose": mistakes = mistakes+1 print("Wrong guess")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question