Update main.py#3531
Conversation
1st try wo VS
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
The implementation has two critical functional issues that violate the task requirements: 1. sorted_variables must be defined at module level, not inside the sort_variables() function. 2. The dictionary must store actual variable VALUES, not names as strings. 3. Tuples are not classified as immutable and should be included in the mutable types check.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| collection_of_coins = {1, 2, 25} | ||
|
|
||
| # write your code here | ||
| def sort_variables(): |
There was a problem hiding this comment.
The task requires sorted_variables to be a module-level dictionary variable, not inside a function. Compare with the example which shows sorted_variables defined at module level after the variables.
| continue | ||
|
|
||
| if isinstance(value, (list, dict, set)): | ||
| mutable.append(name) |
There was a problem hiding this comment.
The values in the lists should be the actual variable VALUES (e.g., b, d), not the variable names as strings. The example shows sorted_variables = {"mutable": [b, d], ...} using variable references, not string names.
| if name.startswith("__"): | ||
| continue | ||
|
|
||
| if isinstance(value, (list, dict, set)): |
There was a problem hiding this comment.
The isinstance check (list, dict, set) is missing tuple - tuples are immutable and should be included in the immutable list, not mutable. Add tuple to the else branch condition.
| else: | ||
| immutable.append(name) | ||
|
|
||
| sorted_variables = { |
There was a problem hiding this comment.
The variable should be named sorted_variables at module level with the actual variable values, not names as strings. Current approach returns names; it should return values like [b, d, my_favourite_films, marks, collection_of_coins] for mutable.
5th again try
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
The implementation has two critical issues that prevent it from meeting the task requirements: 1. Critical Bug - Wrong data stored: Lines 31 and 33 use append(name) which stores variable names as strings (e.g., ['b', 'd']). The task example explicitly shows values should be stored as objects ([b, d]). Change name to value on both lines. 2. Critical Bug - Key typos: The variables dict contains "alucky_number" and "cname" instead of "lucky_number" and "name". These copy-paste errors will cause KeyError exceptions when the code tries to access the correct keys.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| # Check each variable type | ||
| for name, value in variables.items(): | ||
| if type(value) in [list, dict, set]: | ||
| sorted_variables["mutable"].append(name) |
There was a problem hiding this comment.
The code appends name (the variable's name/key as a string) instead of value (the actual variable object). Per the task example, the dictionary should store VALUES like [b, d], not string names like ['b', 'd']. Change name to value on lines 31 and 33.
1st try wo VS