Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shufler() takes exactly 1 positional argument (2 given)

Below is my code.

def __init__(self):
    self.node=[]
    self.fronts=[]
    self.GoalNode=['1','2','3','4','5','6','7','8','0']
    self.StartNode=['1','2','3','4','5','6','7','8','0']
    self.PreviousNode=[]
    self.prePreviousNode=[]
    self.PreviousCount=1

def Solve(self):
    self.shufler(10)
    ......


def shufler(self):

        while True:
            node=self.StartNode

And below is the error message I received:

File "E:\Zoe's file\CMPT 310\Assign 2\astart8puzzle\AI8puzzle\py8puzzel.py", line 18, in Solve
    self.shufler(10)
TypeError: shufler() takes exactly 1 positional argument (2 given)

I don't understand where I gave 2 arguments.

like image 341
zoe Avatar asked Feb 18 '23 21:02

zoe


1 Answers

self.shufler(10)

This calls shufler with two arguments, (1) self and (2) 10. The object to the left of the . is used as the first argument.

To handle the 10 argument, add a second parameter to shufler's definition:

def shufler(self, count):
like image 81
John Kugelman Avatar answered Feb 27 '23 11:02

John Kugelman