title: Can't Break Out of While Loop
body: <p>I wrote the following python code. It takes a list of English words I found on the internet and makes them a list so that I can use them for hangman. Well my problem is that every time I run this program and successfully guess the word, it doesn't break out of the while loop. It just keeps going. I can't figure out why for the life of me. Anyone have any clue as to why it isn't printing the final message to the winner? </p>
  
  <pre><code>import random
  
  words = []
  
  lettersGuessed = []
  
  isGuessed = 0
  
  
  
  wordFile = open(r'C:\Users\Sarah\PycharmProjects\hangman\words.txt')
  
  for word in wordFile:
      words.append(word.rstrip(wordFile.readline()))
  
  
  mysteryWord = random.choice(words)
  
  while len(mysteryWord) &lt;= 1:
      mysteryWord = random.choice(words)
  
  for letter in mysteryWord:
      print("?", end = "")
  print("\n")
  
  def isWon():
      #win conditions
      count = 0
      for letter in mysteryWord:
          if letter in lettersGuessed:
              count += 1
  
          if count == len(mysteryWord):
              isGuessed = 1
  
  
  
  count = 0
  
  while isGuessed == 0:
  
  
      guess = input("Guess a letter \n")
  
      if guess.upper() or guess.lower() in mysteryWord:
          lettersGuessed.append(guess)
          for letter in mysteryWord:
              if letter in lettersGuessed:
                  print(letter, end ='')
              else:
                  print("?", end = '')
      print("\n")
      count = 0
      isWon()
      if isGuessed == 1:
          break
  
  print("Congratulations, you correctly guessed ", mysteryWord)
  </code></pre>