File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change 11"""
2- Пожалуйста, приступайте к этой задаче после того, как вы сделали и получили ревью ко всем остальным задачам
2+ Пожалуйста,
3+ приступайте к этой задаче после того, как вы сделали и получили ревью ко всем остальным задачам
34в этом репозитории. Она значительно сложнее.
45
56
@@ -55,5 +56,29 @@ def generate_chat_history():
5556 return messages
5657
5758
59+ # 1. Вывести айди пользователя, который написал больше всех сообщений.
60+ def is_user_with_max_messages (messages ):
61+ id_list = []
62+ for message in messages :
63+ id_list .append (message ["sent_by" ])
64+ uniq_id_list = list (set (id_list ))
65+
66+ count_of_message_id = {}
67+ for id_uniq in uniq_id_list :
68+ counter = 0
69+ for id in id_list :
70+ if id_uniq == id :
71+ counter += 1
72+ count_of_message_id [id_uniq ] = counter
73+
74+ count_of_message_id_sorted = dict (sorted (count_of_message_id .items (), key = lambda item : item [1 ], reverse = True ))
75+ count_of_message_id_sorted_list = [id for id in count_of_message_id_sorted ]
76+ return count_of_message_id_sorted_list [0 ]
77+
78+
5879if __name__ == "__main__" :
59- print (generate_chat_history ())
80+ messages = generate_chat_history ()
81+ print (is_user_with_max_messages (messages ))
82+
83+
84+
You can’t perform that action at this time.
0 commit comments