TypeError: unsupported operand type(s) for -: 'list' and 'list'

I am having an issue with coordinates with the error: “TypeError: unsupported operand type(s) for -: ‘list’ and ‘list’”.

This is my custom code:

def robocop79_algorithm(self, game_state):
    
    wall_locations = [[1, 13], [2, 13], [3, 13], [4, 13], [5, 13],
                      [6, 13], [7, 13], [8, 13], [9, 13],
                      [10, 13], [11, 13], [12, 13], [13, 13],
                      [14, 13], [15, 13], [16, 13], [17, 13],
                      [18, 13], [19, 13], [20, 13], [21, 13],
                      [22, 13], [23, 13], [24, 13]]

    edge_locations = [[0, 13], [27, 13], [1, 12], [26, 12],
                      [2, 11], [25, 11], [3, 10], [24, 10],
                      [4, 9], [23, 9], [5, 8], [22, 8], [6, 7],
                      [21, 7], [7, 6], [20, 6], [8, 5], [19, 5],
                      [9, 4], [18, 4], [10, 3], [17, 3], [11, 2],
                      [16, 2], [12, 1], [15, 1], [13, 0], [14, 0]]

    for pos in wall_locations:
        if game_state.can_spawn(FILTER, pos):
            game_state.attempt_spawn(FILTER, pos)

    while(game_state.number_affordable(PING) > 0):
        pos - random.choice(edge_locations)
        if game_state.can_spawn(PING, pos):
            game_state.attempt_spawn(PING,  pos)

Please, Thanks!

You can’t substract two list here.
Did you meant an equal sign?

1 Like

Thank you! I am a beginner in python and the help was great!