title: Trouble with Iterations in Function
body: <p>The assignment I'm working on for class is asking us to make a program that calculates integer division by means of repeated subtraction (just like multiplication is equivalent to repeated addition). So far everything works great except for the number of times that the user wants to calculate a quotient. </p>
  
  <p>For some reason, the program always runs just once instead of the number of iterations/inputs that I've prompted the program to execute in the for loop. </p>
  
  <p>Could I get some help with this? I'm new with functions, so I'm sure the program isn't as readable as it could be, but all I need to figure it is what is wrong with my get_num_of_inputs() function and/or num_of_inputs variable. </p>
  
  <p>Thanks!! :)</p>
  
  <pre><code>def main():
      num_of_inputs = get_num_of_inputs()
      numerator, denominator = get_input()
      quotient = calc_quotient(num_of_inputs, numerator, denominator)
      display_output(numerator, denominator, quotient)
  
  def get_num_of_inputs():
      return int(input("What is the number of inputs?: "))
  
  def get_input():
      numerator = int(input("\nEnter the numerator: "))
      denominator = int(input("Enter the denominator (must not be zero): "))
      return numerator, denominator
  
  def calc_quotient(num_of_inputs, numerator, denominator):
  
      if denominator == 0:
          return print("Error: invalid input")
  
      if numerator == 0:
          return 0
  
      if denominator == 1:
          return numerator
  
      if denominator == -1:
          return -numerator
  
      numerator_abs = abs(numerator)
      denominator_abs = abs(denominator)
  
      for iterations in range(num_of_inputs):
          #case 1
          if numerator_abs &gt; denominator_abs:
              result = 5
              acc = numerator_abs
              quotient = 0
  
              while result &gt; 0:
                  acc = acc - denominator_abs
                  result = acc
                  quotient += 1
  
              if result &lt; 0:
                  return quotient - 1
  
              if (numerator &gt; 0 and denominator &gt; 0) or (numerator &lt; 0 and denominator &lt; 0):
                  return quotient
  
              if numerator_abs % denominator_abs == 0 and ((numerator &gt; 0 and denominator &lt; 0) \
                  or (numerator &lt; 0 and denominator &gt; 0)):
                  return -quotient
  
              if numerator_abs % denominator_abs &gt; 0 and ((numerator &gt; 0 and denominator &lt; 0) \
                  or (numerator &lt; 0 and denominator &gt; 0)):
                  return -quotient - 1
          #case 2
          if denominator_abs &gt; numerator_abs:
  
              if (numerator &gt; 0 and denominator &gt; 0) or (numerator &lt; 0 and denominator &lt; 0):
                  return 0
  
              if (numerator &gt; 0 and denominator &lt; 0) or (numerator &lt; 0 and denominator &gt; 0):
                  return -1
          #case 3
          if numerator_abs == denominator_abs:
  
              if (numerator &gt; 0 and denominator &gt; 0) or (numerator &lt; 0 and denominator &lt; 0):
                  return 1
  
              if (numerator &gt; 0 and denominator &lt; 0) or (numerator &lt; 0 and denominator &gt; 0):
                  return -1
  
  
  def display_output(numerator, denominator, quotient):
      print("\nThe quotient of", numerator, "and", denominator, "is:", quotient)
  
  main()
  </code></pre>