title: Clear a list in a function each time it's run
body: <p>I'm kind of new to programming. I'm trying to write an algorithm in python that gives all the prime factors of a number:</p>
  
  <pre><code>factors=[]
  def factor(n):
      for i in range(2,n+1):
          if n%i==0:
              factors.append(i)
              factor(int(n/i))
              break
      return factors
  </code></pre>
  
  <p>It works, but whenever I run the 'factor' function again, it just appends to the already populated 'factors' list - how can I get the list to clear each time the function 'factor' is run?</p>