python - TypeError: 'list' object is not callable when trying to call an object from a dictionary -


I am trying to write the implementation of chess for a school work, but I am an issue that I am fine Can not think. DF Inquiry (self, player): inputstring = input (player.name + ", what is the location of the piece you want to move (like)?") X, y = inputstring Y = int (y) if itself (x, y) itself and [[x, y]] names [1] == player Tags: if self [(x, y)] Camv (self, player): Return (X, Y) Other: Print ("The selected piece can not currently move, try again.") Elif himself [(X, Y)]. Name [1]! = Player. Tags: print ("The piece you are trying to move belongs to the other player, try again.) SPEPIS (player) Alif (X, Y) not in self: print (" Currently there is no piece at the specified place, try again. "Def canmove (self, board, player): # Control if the piece can go in at least one way # Function can also include, If you Lettertonumber = {"a": 1, "b": 2, "c": 3, "d": 4} numbertoletter = {1: "a", 2: "b", 3: "c", 4 : "D"} To step in the self: Order: If you go to [1.5] in the Letter Tonner [self. X] + [[0] and in [1]: [1]: If (letterer [Self. X] + Move [0], on the board itself [1]): If the name itself [1]! = Player. Return truth second: return true to back

When I call this function, the function asks me exactly what the location of the piece I want to move (eg Rock on B1 for the purpose), it checks that the piece is present and if that piece is actually for me, but then generates a TypeError:

  file "Schaak.py" , Line 31, & lt; Module & gt; In the inquiry ("File"), the file "Skakapa", Line 27, in the game (X, Y) = Inquiry (board, player) file "skacap", line 9, in the inquiry board [(X, Y)]. (Board, player) == Correct: type error: 'list' object is not capable of calling  

In the inquiry, itself is a dictionary that is called "board" and itself [(X, Y )] When I ask the code to print [{x, y]] from myself, then it is right that the object is "class: rock" and if I say to print the object then the output is also correct I do not mind how to change syntax, I get this error ( Until I can not produce it with any other error) and in the rest of the code I do not make any mistake while calling myself [[x, y]]

This line canmove ()

  to step in self.canmove:  

means that you can set this feature to a list at some point. The methods and example variables are present in the same name space (in fact, one method is nothing more than a [class] variable that is callable), so that you can not reuse the same name. One name or another must be changed; Since list variables are more likely to be used internally, I suggest changing it to _canmove , unless there is no appropriate name to use it.


Comments