It may seem like the code from cidx > 0 should not be in the else of cidx == 0, but in reality it doesn't matter because if not self.clients or client not in self.client: return was already executed.