Skip to content

Instantly share code, notes, and snippets.

@AaronC81
Last active December 9, 2016 11:23
Show Gist options
  • Save AaronC81/524412a2b02be0081f97f3d87f22fc99 to your computer and use it in GitHub Desktop.
Save AaronC81/524412a2b02be0081f97f3d87f22fc99 to your computer and use it in GitHub Desktop.
Hangman
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