Skip to content

Commit 1a9c141

Browse files
committed
TASK: Optimize get index by chatid
1 parent ab363db commit 1a9c141

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

gamehandler.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ def add_game(self, blackjackgame):
2525
self.GameList.append(blackjackgame)
2626

2727
def get_index_by_chatid(self, chat_id):
28-
index = 0
29-
for game in self.GameList:
28+
for index, game in enumerate(self.GameList):
3029
if game.chat_id == chat_id:
3130
return index
3231
else:
3332
for player in game.players:
3433
if player.user_id == chat_id:
3534
return index
36-
index += 1
35+
3736
return None
3837

3938
def get_game_by_chatid(self, chat_id):

0 commit comments

Comments
 (0)