title: Finding prime factors of a number using "for loop" in python
body: <p>I know how to implement this using a while-loop, but I need to figure out a solution using a for-loop.  For a given num = 56 my code below outputs <code>[2, 7, 4]</code>, whereas the right answer would be <code>[2,2,2,7]</code>. where am I going wrong?</p>
  
  <pre><code>def prime_fac(num):
      a = num
      pf = []
      for x in range(2,a):
          if a % x == 0:
              if x == 2 or x == 3:
                  pf.append(x)
                  a = a//x
              else:
                  for y in range(2,x):
                      if (x % y) == 0:
                          break
                  else:
                      pf.append(x)
                      a = a // x
          else:
              continue
      if a&gt;1:
          pf.append(a)
      print (f"Prime factors of {num} are {pf}")
  number = int(input('Enter a number to find its prime factors: '))
  prime_fac(number)
  </code></pre>