title: Python3: Find word in list using while-loop
body: <p>A simple question, that I've actually had a hard time finding a solution to, as most suggest using the much easier to work with, for loop.</p>
  
  <p>I have an assignment that tells me explicitly to use the while loop to return either true or false, based on if a string occurs in a list.</p>
  
  <p>My current solution (which works) is as follows:</p>
  
  <pre><code>def word_in_list(word, words):
  x=0
  length = int(len(words)) -1
  
  while words[x] != word and x &lt; length:
      x = x+1
  
      if words[x] == word:
          print (True)
  
      elif x == length and words[x] != word:
          print (False)
  </code></pre>
  
  <p>My biggest issue has been limiting the function to the length of the list, otherwise I get an error stating "list index out of range".</p>
  
  <p>However, as this is a rather clunky way of doing something so simple, I'm looking for suggestions on how to streamline it a little - if there's a way that is. And as stated, the for-loop, that you'd normally use, is not an option.</p>