title: Setting While Loop to Loop Maximum of 3 Times
body: <p>I'm trying to get my <code>while</code> loop to loop a maximum of 3 times before the program quits while also informing the user of their remaining attempts.</p>
  
  <pre><code>def main():
      valid = 0
      while (valid == 0):
          valid = checkValid ()
      print ('and the program continues on with User_Input2()...')
      #User_Input2()
  </code></pre>
  
  <p>And here is the code for <code>checkValid()</code></p>
  
  <pre><code>def checkValid():
      if ((iVelocity &lt; 20) or (iVelocity &gt; 800) or (iTrajectory &lt; 5) or (iTrajectory &gt; 80)):
          result = 0
      else:
          result = 1
      return result
  </code></pre>
  
  <p>And what the main program looks like:</p>
  
  <pre><code>iVelocity = float(input('Please enter an initial velocity between 20 to 800 m/s: ' ))
  iTrajectory = float(input('Please enter an initial trajectory angle between 5 to 80 degrees: '))
  
  main()
  </code></pre>
  
  <p>I'm not sure where to add code in either function to get it to loop (or if I need to create something along the lines of <code>def counter():</code>), inform the user of their remaining attempts, and how to quit the program if all 3 attempts have been used.</p>