title: cs50: pset6: Why both of these while loops don't work as expected?
body: <p>Having trouble figuring out why these loops don't work as expected. I want the user to be entering a string (height) and if it contains characters, request a height again until certain integers are typed.</p>
  <p>First loop: Here. I'm expecting that if I put in a number from 1 until 8, the loop will break, but it doesn't! It keeps requesting the height.</p>
  <pre><code>height = input(&quot;What's the height?\n&quot;)
  while type(height) != int or (height &lt; 1 or height &gt;= 9):
      height = input(&quot;What's the height?\n&quot;)
  </code></pre>
  <p>Second loop: Expecting the same. Loop doesn't break, keeps asking for height.</p>
  <pre><code>while True:
      height = input(&quot;What's the height?\n&quot;)
      if type(height) == int and (height &gt;= 1 and height &lt;= 8):
          break 
  </code></pre>
  <p>Just got into Python but this doesn't seem to be a Python problem, more like something that I'm missing on while loops.</p>
  <p><strong>EDIT</strong></p>
  <p>Made it work finally. This worked like a charm.</p>
  <pre><code>while True:
  height = input(&quot;What's the height?\n&quot;)
  if not(height.isalpha()):
      if not(height.isspace()):
          if height != &quot;&quot;:
              height = int(height)
              if height &gt;= 1 and height &lt;= 8:
                  break 
  </code></pre>