Lesson 9: Hangman v1

posted Dec 15, 2017, 8:02 AM by Attila Lengyel
print("Let's play Hangman")
word = input("Give me the word:")

word_dash = ""
for x in range(0, len(word)):
  word_dash += "_ "
 
print (word_dash)
 
good_letters = ""

guess = input("Guess a letter:")

if word.find(guess) > -1:
  print("Correct guess!")
  good_letters += guess
else:
  print("Wrong guess!")
 
word_dash = ""
for x in range(0, len(word)):
  if good_letters.find(word[x]) > -1:
    word_dash += word[x] + " "
  else:
    word_dash += "_ "

print(word_dash)



 
Comments