Last active
December 9, 2016 11:23
-
-
Save AaronC81/524412a2b02be0081f97f3d87f22fc99 to your computer and use it in GitHub Desktop.
Hangman
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
word = list(map(lambda x: (x, False), "hello")) | |
incorrect_guesses = "" | |
while not all(map(lambda x: x[1], word)): | |
print(*(letter if guessed else "_" for letter, guessed in word)) | |
print("Incorrect guesses are: ", *incorrect_guesses) | |
new_letter = input("Enter a guess: ") | |
if len(new_letter) != 1: | |
print("Only input 1 letter!") | |
continue | |
if new_letter in list(map(lambda x: x[0], word)): | |
word = list(map(lambda x: (x[0], True) if x[0] == new_letter else (x[0], x[1]), word)) | |
else: | |
print("That's not a letter in the word!") | |
print("----") | |
print("You got it!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment