title: How to fix "During handling of the above exception, another exception occurred: "
body: <p>How do i fix this error, whenever i enter data that should cause an exception more than once the program crashes. Here is my code and what it outputs, it should keep repeating until correct data is entered.</p>
  <p><a href="https://i.stack.imgur.com/CgeFh.png" rel="nofollow noreferrer">code</a></p>
  <pre><code>flag=False
  
  while flag==False:
      try:
          number=int(input(&quot;Enter number of books: &quot;))
      except ValueError:
          print(&quot;Please enter number of books as a positive whole number &quot;)
          number=int(input(&quot;Enter number of books: &quot;))
      else:
          flag=True
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Okxg4.png" rel="nofollow noreferrer">errors</a></p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Users\Alex\OneDrive\Documents\ComputerScience\Intro2.py&quot;, line 5, in &lt;module&gt;
      number=int(input(&quot;Enter number of books: &quot;))
  ValueError: invalid literal for int() with base 10: '3.3'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;C:\Users\Alex\OneDrive\Documents\ComputerScience\Intro2.py&quot;, line 8, in &lt;module&gt;
  number=int(input(&quot;Enter number of books: &quot;))
  </code></pre>
  <p>ValueError: invalid literal for int() with base 10: '3.4'</p>