title: My python code does what it is intended to do, but breaks/keeps going with the try/catch blocks?
body: <pre><code>#A 0-50 Units is multiplied by $0.59 (multiply by 0.59)
  #B Up to 150 Units (minus 50 and multiply remaning by 0.65)
  #C Greater than 150 Units(minus 150(first 150 = $94.50) and multiply remaining by 0.68)
  #D All Residential charges are fixed @ $13.00(always add $13)
                  
  print (&quot;      *        SKELEC Electricity Bill Calculator        *       &quot;)
  
  def main():
      
      while True:
          try:
              prev_month = float(input(&quot;Enter the meter reading for the previous month\n&quot;))
              break
          except ValueError:
              print(&quot;Invalid value entered. Please try again.&quot;)
              continue
          
      if prev_month &lt; 0:
              print(&quot;Please enter a valid reading.&quot;)
              main()
              
      while True:
          try:
              pres_month = float(input(&quot;Enter the meter reading for the current month\n&quot;))
              break
          except ValueError:
              print(&quot;Invalid value entered. Please try again.&quot;)
              continue
          
      if pres_month &lt; 0:
              print(&quot;Please enter a valid reading.&quot;)
              main()
  
      if pres_month &lt; prev_month:
              print(&quot;Present month value is lower than previous month value&quot;)
              main()
  
      units_kwh = pres_month - prev_month #Variable for the subtraction of present month and previous month
      
      print(&quot;Usage = &quot;, units_kwh,&quot;kw/h&quot;)
  
      if units_kwh &lt;= 50: #Argument for 0-50 kwh units
          Energy_charge = units_kwh * 0.59
          print(&quot;Your charge for the month is, $&quot;, Energy_charge)
  
      elif units_kwh &gt; 50 and units_kwh &lt;= 150: #Argument for units up to 150kwh
              units_fifty = units_kwh - 50
              Energy_charge = (units_fifty * 0.65 + 29.50) + 13.00
              print(&quot;Your charge for the month is, $&quot;, Energy_charge)
  
  
      elif units_kwh &gt; 150: #Argument for units over 150kwh
              Energy_charge = ((units_kwh - 150) * 0.68 + 94.50) + 13.00
              print(&quot;Your charge for the month is, $&quot;, Energy_charge)
              
      print(&quot;Residential Charge of $13.00 added&quot;)
  
              
  main()
  </code></pre>
  <p>Everything works well, but if an incorrect value is entered at first(such as characters), the code unwantedly loops once it gives the final result. I've tried moving the try/catch blocks outside of the loop, double checking my conditional statements and proofreading to see how the code could loop in such a way. I'm convinced the problem lays in the try/catch blocks, but I'm fairly new to coding with Python so I am unsure of how to fix this?</p>