everything but the bonus - #21
Open
mxlZUBENKO wants to merge 3 commits into
Open
Conversation
krepysh
suggested changes
Feb 22, 2023
| 'Маша': False, | ||
| } | ||
| for name in is_male: | ||
| if is_male[name] == True: |
There was a problem hiding this comment.
Лучше не сравнивать с True, просто if is_male[name]:
| ['Вася', 'Маша', 'Саша', 'Женя'], | ||
| ['Оля', 'Петя', 'Гриша'], | ||
| ] | ||
| print(f'Всего груп: {len(groups)}') |
| for student in students: | ||
| name = student['first_name'] | ||
| if names.get(name) == None: | ||
| names[name] = 1 |
There was a problem hiding this comment.
Тут можно без if обойтись
Suggested change
| names[name] = 1 | |
| names[name] = names.get(name, 0) + 1 |
| for student in students: | ||
| name = student['first_name'] | ||
| if names.get(name) == None: | ||
| names[name] = 1 |
There was a problem hiding this comment.
Здесь можно использовать решение предыдущей задачи, если обернуть его в функцию.
| for grade in school_students: | ||
| names = {} | ||
| for student in grade: | ||
| name = student['first_name'] |
There was a problem hiding this comment.
Аналогично, можно использовать решение первой задачи тут.
| number_responses_per_user = {} | ||
| for _ in chat_history: | ||
| message_id = _['id'] | ||
| for i in number_answers: |
| else: | ||
| number_responses_per_user[_['sent_by']] += number_answers[i] | ||
| most_cited = max(number_responses_per_user.values()) | ||
| for _ in number_responses_per_user: |
| message_id = _['id'] | ||
| for i in number_answers: | ||
| if i == message_id: | ||
| if number_responses_per_user.get(_['sent_by']) == None: |
There was a problem hiding this comment.
Если избавимся от if так же как раньше, код значительно упростится.
| who_saw = [] | ||
| message_list = user_messages[_] | ||
| for i in message_list: | ||
| for j in chat_history: |
There was a problem hiding this comment.
что такое i, j? переименуй на что-то более понятное плиз
| by = _['id'] | ||
| beginning = _['reply_for'] | ||
| if answer == False: | ||
| while beginning != None and beginning != []: |
There was a problem hiding this comment.
is not None
любой не пустой словарь будет true, можно сделать
Suggested change
| while beginning != None and beginning != []: | |
| while beginning is not None and beginning: |
… решения задач в функции для дальнейшего использования
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.