title: How can i stop a for-loop iterating when the input is not valid? (not allowed to use a while loop) - Python
body: <pre><code>for i in range (0, 3): 
      
      print() # When iterates creates a space from last section
      
      raw_mark = int(input(&quot;What was student: &quot; + str(student_id[i]) + &quot;'s raw mark (0 - 100)?: &quot;))
      
      days_late = int(input(&quot;How many days late was that student (0 - 5)?: &quot;))
      
      penalty = (days_late * 5)
      
      final_mark = (raw_mark - penalty)
  
      # Selection for validation 
      
      if 0 &lt;= raw_mark &lt;= 100 and 0 &lt;= days_late &lt;= 5 and final_mark &gt;= 40:
          
          print(&quot;Student ID:&quot;, str(student_id[i]))
          
          print() # Spacing for user readability
          
          print(&quot;Raw mark was:&quot;, str(raw_mark),&quot;but due to the assignment being handed in&quot;,
                str(days_late),&quot;days late, there is a penalty of:&quot;, str(penalty),&quot;marks.&quot;)
          
          print()
          
          print(&quot;This means that the result is now:&quot;, final_mark,&quot;(this was not a capped mark)&quot;)
  
           
          
      elif 0 &lt;= raw_mark &lt;= 100 and 0 &lt;= days_late &lt;= 5 and final_mark &lt; 40: # Final mark was below 40 so mark must be capped
          
          print(&quot;Student ID:&quot;, str(student_id[i]))
          
          print()
          
          print(&quot;Raw mark was:&quot;, str(raw_mark),&quot;but due to the assignment being handed in&quot;,
                str(days_late),&quot;days late, there is a penalty of:&quot;, str(penalty),&quot;marks.&quot;)
          
          print()
          
          print(&quot;Therefore, as your final mark has dipped below 40, we have capped your grade at 40 marks.&quot;)
  
          
      else:
          print(&quot;Error, please try again with applicable values&quot;)
  </code></pre>
  <p>At the else i would like the loop to loop back through but not having iterated i to the next value, so that it can be infinite until all 3 valid inputs are entered... cannot use a while loop nor can i put the if - elif- else outside the loop. Nor can i use a function :(</p>