'Why wont my if statement accept my condition python [duplicate]

Beginner here, whenever I try to run the code with sum as 20 for example, it only returns [2,10], rather than the intended [2,10,4,5,5,4,10,2]

def Factors(num):
    factor1=2
    factors=[]
    while factor1<num:
        while num%factor1 == 0:
            factors.append(factor1)
            factors.append(num/factor1)
            factor1+=1
            continue
        if num%factor1 != 0:
            factor1+=1
        
        return factors


Solution 1:[1]

I rewrote some of this code and this is what I came up with.

factors = []

def Factor(num):
    first_factor = 1
    while first_factor <= num:
        if num % first_factor == 0:
            factors.append(first_factor)
            first_factor += 1
        else:
            first_factor += 1

    return(factors)

print(Factor(20))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Srivatsa Rao