My function not returning any result in python?
so I was doing a little math study and decided to recreate a simple assignment in python which is to find the factor pairs of a number. I did that quite easily but now I have a little issue which I have tried to figure out but to no avail. Here's the code: # Find the factor pairs of a given number def getFactorPairs(n=0): num = n factors = [] pair = None for p in range(1, num + 1): for r in range(1, num + 1): if p * r == num: pair = (p, r) if (r, p) not in factors: factors.append(pair) else: continue return factors print(getFactorPairs(120)) # Works fine getFactorPairs(120) # This doesn't give
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.