title: How do I loop one input instead of restarting the entire program?
body: <p>I have a simple ice cream program, everything works. But how do I loop a single input like scoops if the input is invalid? Currently if the input is incorrect it re-asks the user for the first input again. Meaning if I enter vanilla for the flavor and 7 for the number of scoops, it will print the error message, then instead of re-asking how many scoops you'd like, it asks you what flavor you'd like. How would I fix this for my three inputs throughout the program? I would still like the program to restart after a valid order is entered. Thank you for your time.</p>
  <p>Program code:</p>
  <pre><code>#Error for wrong flavor selection
  class FlavorError(Exception):
      def __init__(self, flavors, message):
          Exception.__init__(self, flavors, message)
          self.flavors = flavors
  
  #Error for wrong number of scoops selection
  class ScoopsError(Exception):
      def __init__(self, scoops, message):
          Exception.__init__(self, scoops, message)
          self.scoops = scoops
  
  #Error for wrong carrier selection
  class HoldingsError(Exception):
      def __init__(self, holdings, message):
          Exception.__init__(self, holdings, message)
          self.holdings = holdings
  
  
  def main():
      #Creating Values
      flavors= &quot; &quot;
      scoops = &quot; &quot;
      holdings = &quot; &quot;
      while True:
          try:
              #MENU / INFORMATION
              print(&quot;Flavors: vanilla, chocolate, strawberry, mint, pistachio, and spumoni&quot;)
              print(&quot;Number of scoops: 1, 2, 3&quot;)
              print(&quot;Ways to eat: bowl or cone&quot;)
              print()
              #FLAVOR INPUT
              flavors = input(&quot;Enter a flavor of ice cream: &quot;).lower()
              print()
              #ERROR CHECK
              if flavors not in ['vanilla', 'chocolate', 'strawberry', 'mint', 'pistachio', 'spumoni']:
                  raise FlavorError(flavors, &quot;is not on the menu.&quot;)
              #NUMBER OF SCOOPS INPUT
              scoops = int(input(&quot;Enter the number of scoops: &quot;))
              print()
              #ERROR CHECK
              if scoops &gt; 3 or scoops &lt;= 0:
                  raise ScoopsError(scoops, 'We do not offer that many scoops!')
              #CARRIER INPUT
              holdings = input(&quot;Would you like a cone or bowl? &quot;)
              print()
              #ERROR CHECK
              if holdings not in ['bowl', 'cone']:
                  raise HoldingsError(holdings, 'Please select between a bowl or a cone')
              print(scoops , &quot;scoops of&quot; , flavors , &quot;in a&quot; , holdings)
              print()
          except Exception as e:
              print(&quot;Invalid choice! try again!&quot;+str(e))
              print()
  
  main()
  </code></pre>