title: limiting invalid input in python 3
body: <p>I need to limit the number of invalid inputs allowed so that after the given amount of tries the program exits.</p>
  
  <p>Invalid is defined by the input being less than zero.</p>
  
  <p>The number of attempts let say is 3.</p>
  
  <pre><code>def number():        
      number = float(input('please enter a number (must be greater thatn zero): '))
  
      if number &gt;= 0 :    
          print ('you choose number:', number)    
      else:
          print ('invalid input')    
          return 
  
  number()
  </code></pre>
  
  <p>How would I limit the number of invalid input attempts and make it so that the code would return to asking the question again and prompt for input but still keep track of previous attempts?</p>