title: Getting a single set of elements using loops
body: <p>Whenever I append an element into a new list in a loop, i get a number of lists that repeats the elements. How do i get a single list with all elements without repeating them?</p>
  
  <pre><code>n, r = [5, 2]
  ans = 0
  l = [0]
  while n-1&gt;0:
      ans = ans+r
      for i in range(ans):
  
          if ans not in l:
              l.append(ans)
          print(l)
      n-=1
  
  
  
  #I was hoping to get this answer:
   [0,2,4,6,8]
  #Instead, I got this:
   [0, 2]
   [0, 2]
   [0, 2, 4]
   [0, 2, 4]
   [0, 2, 4]
   [0, 2, 4]
   [0, 2, 4, 6]
   [0, 2, 4, 6]
   [0, 2, 4, 6]
   [0, 2, 4, 6]
   [0, 2, 4, 6]
   [0, 2, 4, 6]
   [0, 2, 4, 6, 8]
   [0, 2, 4, 6, 8]
   [0, 2, 4, 6, 8]
   [0, 2, 4, 6, 8]
   [0, 2, 4, 6, 8]
   [0, 2, 4, 6, 8]
   [0, 2, 4, 6, 8]
   [0, 2, 4, 6, 8]
  </code></pre>