Python Forum
Missing positional arguments error??
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Missing positional arguments error??
#1
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?
Reply
#2
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.
Reply
#3
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)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: __init__() missing 1 required positional argument: 'successor siki 1 4,302 Mar-08-2021, 02:05 PM
Last Post: Larz60+
  Missing 1 required positional argument in python code edwinostby 7 9,933 Jan-19-2021, 12:52 PM
Last Post: Serafim
  TypeError: Missing required positional arguments liaisa 7 28,980 Sep-25-2020, 08:16 PM
Last Post: deanhystad
  missing positional argument error programmert 1 2,821 Oct-18-2019, 11:05 AM
Last Post: Larz60+
  missing 1 required positional argument jedmond2 4 6,690 Sep-19-2019, 12:00 PM
Last Post: jefsummers
  missing 1 required positional argument mcgrim 10 19,755 May-07-2019, 09:02 PM
Last Post: Yoriz
  TypeError: __init__() missing 3 required positional arguments Pythonhelp82 6 23,127 Jan-24-2019, 04:25 AM
Last Post: Pythonhelp82
  TypeError: method missing 1 positional argument koolinka 4 5,028 Nov-18-2018, 04:53 PM
Last Post: ichabod801
  another positional argument error (...and executing objects stored in a list) itmustbebunnies 7 4,210 Nov-16-2018, 07:18 PM
Last Post: itmustbebunnies
  Class positional argument error itmustbebunnies 2 2,995 Nov-07-2018, 11:09 AM
Last Post: stullis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020