1

I've got the following code:

if(promovePeao(board,player) or (not getMovesPecas(board)['W'])):
   print("HELLO")

My intention is to check if there are any players in the last row of the boards

def promovePeao(self, board, player):
    if(player == 'B'):
        for a in (1,9):
            if(board[(1,a)] == player):
                return True
        return False
    else:
        for b in (1,9):
            if(board[(8,b)] == player):
                return True
        return False

But when I execute the code, I receive the error:

TypeError: promovePeao() missing 1 required positional argument: 'player'

Any ideias why?

Dominique
  • 16,450
  • 15
  • 56
  • 112
Bny4W
  • 21
  • 5

1 Answers1

0

You are defining promovePeao like a method, but calling it like a function. You are getting the error because the function expects the self argument, but it is not getting automatically passed because it is not being called on an object. Change it to this:

def promovePeao(board, player): #Note that there is no self argument
    if(player == 'B'):
        for a in (1,9):
            if(board[(1,a)] == player):
                return True
        return False
    else:
        for b in (1,9):
            if(board[(8,b)] == player):
                return True
        return False
Pika Supports Ukraine
  • 3,612
  • 10
  • 26
  • 42