title: How do I take a value and divide it amongst the elements of a set, in increments of 1/32?
body: <p>I have a need to divide a length into approximately equal sections, by 1/32nds (for imperial measurements). I have written my code to divide lengths that evenly divide, but I'm having trouble with lengths that do not divide evenly (usually in thirds). As you will see in the code below, for the lengths that do not evenly divide, I use floored division to get a &quot;base value&quot; for the section, and then I calculate the remainder. I would like to take the remainder and have a while loop subtract from the remainder, 1/32 at a time, and add to each element in the list until the remainder is zero. Ultimately, one of the elements will be greater or less than the other elements by 1/32, depending on when the remainder depletes.
  I keep getting stuck on the loop, and I'm not sure how to properly decrement as each element is independently increased by 1/32. Please see code section below and advise, thank you.</p>
  <p>Here is the section of my code that addresses section_nums that will not divide the true_length evenly.</p>
  <pre><code>else:
      base_value = true_length // section_num
      remainder_value = true_length % section_num
      section_list = [base_value] * int(section_num)
      while remainder_value &gt; 0:
          for index in range(len(section_list)):
              section_list[index] = section_list[index] + (1/32)
              subtractor_value = (len(section_list)) * (1/32)
              remainder_value = remainder_value - subtractor_value
      print(&quot;Each section will be&quot;, section_list)
  </code></pre>