Форум сайта python.su
0
@bot.message_handler(content_types= ['text']) def send_text(message): if list(message.text.lower())[0] == '~' and list(message.text.lower())[1] == '@': list_of_players.append(str(message.text)) for i in list_of_players: to_show_list[i] = to_show_list.get(i, 0) + 1 for key in list(to_show_list.keys()): if to_show_list[key] == 5: bot.send_message(message.chat.id, ('Дай этому ' + str(key) + ' бан!')) del to_show_list[key] for i in list_of_players: if i == key: list_of_ban.append(key) #Последний блок for i in list_of_players: if i in list(set(list_of_ban)): for j in list_of_ban: if i == j: list_of_players.remove(i) to_show_list.clear()
Отредактировано danker038 (Июль 11, 2019 03:12:28)
Офлайн
253
В питоне принято создавать новый список
list_of_players = [i for i in list_of_players if i not in list_of_ban]
list_of_players -= list_of_ban
Отредактировано doza_and (Июль 11, 2019 08:37:11)
Офлайн