title: I am trying to write a code for something similar to hangman, but it is not working
body: <p>I'm trying to code a hangman kind of thing but even after the word is guessed correctly the loop continues.
  It seems like the bit that isn't working is the <code>if word == ("".join(userword))</code> bit at the end, but I don't know what I'm doing wrong   .</p>
  
  <pre><code>import random
  word = random.choice(["apple", "orange", "pineapple"])
  word = list(word)
  life = 5
  userword = []
  
  for i in range (len(word)):
      userword.append("_")
  
  while life &gt; 0: 
      print("".join(userword))
      print("enter a letter")
      letter = input()
      letterinword = False
      for i in range(len(word)):
          if word[i] == letter:
              userword[i] = letter
              letterinword = True
  
      if letterinword == False:
          life = life - 1
  
      if word == ("".join(userword)):
          break
  </code></pre>