title: How to moderate elements of a list while in a loop
body: <p>How do I make sure that the elements in b don't go below 0 or above 10? </p>
  
  <p>I.e. when 5 decreases to 0 in list b, how can I get the program to increase it back to 1 and then make increments of 1?</p>
  
  <pre><code>a = [2, 5, 7]
  b = []
  m = True
  counter = 1
  
  while m == True:
  
      for i in a:
  
          if i &gt;= 5:
              i -= counter
              b.append(i)
          else:
              i += counter
              b.append(i)
  
          if len(a) == len(b):
              counter += 1
              print(b)
              b.clear()
  
          if counter == 15:
              m = False
  
  """
  Current output: 
  [2, 5, 7]
  [3, 4, 6]
  [4, 3, 5]
  [5, 2, 4]
  [6, 1, 3]
  [7, 0, 2]
  [8, -1, 1]
  [9, -2, 0]
  [10, -3, -1]
  [11, -4, -2]
  
  Expected output:
  [2, 5, 7]
  [3, 4, 6]
  [4, 3, 5]
  [5, 2, 4]
  [6, 1, 3]
  [7, 0, 2]
  [8, 1, 1]
  [9, 2, 0]
  [10, 3, 1]
  [9, 4, 2]
  """
  </code></pre>