Skip to content

Instantly share code, notes, and snippets.

@Yoiter
Created October 19, 2017 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yoiter/699ccf7afe2df78e8754bdea78e9f8c6 to your computer and use it in GitHub Desktop.
Save Yoiter/699ccf7afe2df78e8754bdea78e9f8c6 to your computer and use it in GitHub Desktop.
def drawing(tries): #this is the function that draws gallows depending on how many tries the player has left
if tries == 6:
print(" _______")
print("| |")
print("|")
print("|")
print("|")
print("|")
print("|")
elif tries == 5:
print(" _______")
print("| |")
print("| 0")
print("|")
print("|")
print("|")
print("|")
elif tries == 4:
print(" _______")
print("| |")
print("| 0")
print("| |")
print("|")
print("|")
print("|")
elif tries == 3:
print(" _______")
print("| |")
print("| 0")
print("| |\ ")
print("|")
print("|")
print("|")
elif tries == 2:
print(" _______")
print("| |")
print("| 0")
print("| /|\ ")
print("|")
print("|")
print("|")
elif tries == 1:
print(" _______")
print("| |")
print("| 0")
print("| /|\ ")
print("| |")
print("|")
print("|")
elif tries == 0:
print(" _______")
print("| |")
print("| 0")
print("| /|\ ")
print("| |")
print("| / \ ")
print("|")
print("▒█░▒█ ░█▀▀█ ▒█▄░▒█ ▒█▀▀█ ▒█▀▄▀█ ░█▀▀█ ▒█▄░▒█ ")
print("▒█▀▀█ ▒█▄▄█ ▒█▒█▒█ ▒█░▄▄ ▒█▒█▒█ ▒█▄▄█ ▒█▒█▒█ ")
print("▒█░▒█ ▒█░▒█ ▒█░░▀█ ▒█▄▄█ ▒█░░▒█ ▒█░▒█ ▒█░░▀█")
print("by Ubisoft")
print("웃 - don't let me die!")
word = input("The word: ")
progress = ["_"] * len(word)
print("You have 7 tries, good luck")
tries = 7 #this makes it so taht the player can only get a guess wrong 7 times
print("type 'x' to quit")
guess = input("Guess a letter: ")
while guess != ">:(": #this is the while loop that keeps on going until >:( is typed or until loss/victory both of which break this loop
for i in range(len(word)): #this is the loop that goes through each letter in the word
if guess == word[i]: #this if statement compares the guess to each letter in the word
progress[i] = guess
if guess not in word: #this if statement checks if the guess is in the word, and if it is not then it takes away a try
tries = tries - 1
final = " ".join(progress)
ezfinal = "".join(progress) #this is the list that is compared to the word to see if the player guessed all the letters in the word correct
drawing(tries) #this is what activates the drawing function and inputs the amount of tries left as the parameter
if ezfinal == word: #this if statement compares the progress list to the initial word
print(final)
print("Good Job! You got it!")
break
elif tries == 0: #this is an if statement that prints a few things and breaks the while loop in case the player runs out of tries
print("You ran out of tries, better luck next time!")
print("The word was: " + word)
print("█░░ █▀▀█ █▀▀ █▀▀ █▀▀█ ")
print("█░░ █░░█ ▀▀█ █▀▀ █▄▄▀ ")
print("▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ ▀░▀▀ ")
break
print(final)
print("You have " + str(tries) + " tries left")
guess = input("Guess a letter: ")
@Yoiter
Copy link
Author

Yoiter commented Oct 19, 2017

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment