Q:

Python - isPrime and factList

function file: 
def factList(p,n1):
    counter = 1
    while counter < n1:
        if n1 % counter == 0:
            p.append(counter)
        counter = counter + 1

def isPrime(nbr):
    counter1 = 1
    factList(nbr)
    while counter1 < nbr:
        if len(nbr) == 2:
            return True
        else:
            return False
        counter = counter + 1

functiontester file
lstt = []
n1 = 16

factList(lstt, n1)
print "The factors are of", n1, "are", lstt

nbr = 20
if isPrime(nbr):
    print "Is Prime"

P.S. Please do not delete, change, or edit any part of the factor list. (even if it's simpler)
I am trying to make it so I can use my factor list to determine if my number is prime (only one number). If you could please help me make it so it works, please only use basic function like the ones I have used above. Thank you.
When I run it I get -
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 
The factors are of 16 are [1, 2, 4, 8]

Traceback (most recent call last):
  File "\\giant\home\2018\patelpre\FunctTstr.py", line 40, in <module>
    if isPrime(nbr):
TypeError: isPrime() takes exactly 2 arguments (1 given)
>>> 

A:

Based on the code sample, a TypeError would be caused by passing only 1 instead of 2 arguments into factList() on line 2 of the isPrime() function.
In the isPrime() function, you try to use factList() with only an integer when it requires a list AND an integer
factList(nbr)

This will cause a TypeError. You either DO want isPrime() to take two arguments (a list and an integer) and pass those in, or you want to create an empty list in isPrime() and pass that into factList() with nbr.

