I have such code in Python:
def send_start(self, player):
for p in self.players:
player["socket"].send_cmd('<player id="%s" name="%s" you="%s" avatar="*.png" bank="%s" />'%(self.players.index(p)+1, p['name'], int(player["pid"]==p["pid"]), 0))
player["socket"].send_cmd('<game playerid="%s" />'%(self.turnnow))
player["socket"].send_cmd("<start />")
And the error is in the title of this post. What’s wrong?
Your code would fail if
self.turnnowis an empty tuple:This is because a parenthesized expression in Python does not automatically become a tuple if the tuple would have only one element.
(expr)is equivalent toexpr.(expr, )is equivalent to a one-element tuple holdingexpras the first element. So, try adding a comma afterself.turnnowin the secondprintstatement.