Python Forum

Full Version: Missing positional arguments error??
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
def lattice_moves(n, m, l):
    if n==0 and m==0 and l==0:
        return 1
    elif n==0 and m==0:
        return (lattice_moves(n, m, (l-1)))
    elif n==0 and l==0:
        return (lattice_moves(n, (m-1), 1))
    elif m==0 and l==0:
        return (lattice_moves((n-1), m, l))
    elif n==0:
        return (lattice_moves((n, m-1, l)))+(lattice_moves(n, m, (l-1)))
    elif m==0:
        return (lattice_moves(((n-1), m, l)))+(lattice_moves(n, m, (l-1)))
    elif l==0:
        return (lattice_moves(((n-1), m, l)))+(lattice_moves(n, (m-1), l))
    else:
        return (lattice_moves(((n-1), m, l)))+(lattice_moves(n, (m-1), l))+(lattice_moves(n, m, (l-1)))
print(lattice_moves(2, 2, 2))
I keep getting the error "
Error:
File "C:\Users\gc2190\untitled0.py", line 34, in lattice_moves return (lattice_moves(((n-1), m, l)))+(lattice_moves(n, (m-1), l))+(lattice_moves(n, m, (l-1))) TypeError: lattice_moves() missing 2 required positional arguments: 'm' and 'l'", can anyone see a way to fix it?
Please always post complete unaltered error traceback ( in error tags )
everything in there has value for diagnosing the problem.

Second, please make sure line numbers in error match numbers in supplied code,
or at least supply a translation of the line numbers (if snippet supplied).
Make sure error message is from code supplied.
You are using too many brackets. Remove the redundant.

def lattice_moves(n, m, l):
    if n==0 and m==0 and l==0:
        return 1
    elif n==0 and m==0:
        return lattice_moves(n, m, l-1)
    elif n==0 and l==0:
        return lattice_moves(n, m-1, 1)
    elif m==0 and l==0:
        return lattice_moves(n-1, m, l)
    elif n==0:
        return lattice_moves(n, m-1, l) + lattice_moves(n, m, l-1)
    elif m==0:
        return lattice_moves(n-1, m, l) + lattice_moves(n, m, l-1)
    elif l==0:
        return lattice_moves(n-1, m, l) + lattice_moves(n, m-1, l)
    else:
        return lattice_moves(n-1, m, l) + lattice_moves(n, m-1, l) + lattice_moves(n, m, l-1)