That error message is saying that self.command() is receiving null for the minion argument.
The minion argument is where you put soldier in self.command(soldier, "defend", target).
There seems to be more elements in defend than there are in soldiers.
while True:
# Use a for-loop to assign each soldier to a corresponding defend[] target
# Use command(soldier, "defend", thang) or command(soldier, "defend", position)
for i in range(len(defend)):
hero.command(soldier, "defend", {"x": 98, "y": 28)
hero.command(soldier, "defend", {"x": 84, "y": 7})
pass
T_RBRACE probably means Token: Right Brace, which is this: }
T_RPAR probably means Token: Right Parenthesis, which is this: )
So, that error is saying that the parser expected a } but found a ) instead.
You can see what line the parser found the unexpected token in by looking for the line highlighted in red.
When a left brace/bracket/parenthesis is parsed, the right brace/bracket/parenthesis (matching the type of the left) is expected to close it.
( { [ ] } ) -- sets matching
vs
( [ { ) } ] -- sets not matching
So, your minion argument is receiving null. Somehow, your hero.command gets None instead of a soldier to command. How’s None getting stored into soldier?
for i in range(len(defend)):
soldier = soldiers[i]
...
Just focus on these lines.
Compare the length of defend to the length of soldiers.
My post from earlier
Near the top of your program, you have already defined two positions inside the defend array.
Perhaps that is the root cause of this issue.
# there are 5 items in this list:
fiveItems = [10, 20, 30, 40, 50]
# there are 3 items in this list:
threeItems = [71, 72, 73]
for i in range(len(fiveItems)): # this for loop iterates 5 times (i counts from 0 to 4),
# because there are 5 items in fiveItems
currentItem = threeItems[i] # what happens when i is 3 or 4?
hero.say(currentItem)
hero.wait(1)