Skip to content

Update main.py#3531

Open
naderidkeidek-star wants to merge 1 commit into
mate-academy:masterfrom
naderidkeidek-star:master
Open

Update main.py#3531
naderidkeidek-star wants to merge 1 commit into
mate-academy:masterfrom
naderidkeidek-star:master

Conversation

@naderidkeidek-star
Copy link
Copy Markdown

1st try wo VS

1st try wo VS
Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread app/main.py
collection_of_coins = {1, 2, 25}

# write your code here
def sort_variables():
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread app/main.py
continue

if isinstance(value, (list, dict, set)):
mutable.append(name)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread app/main.py
if name.startswith("__"):
continue

if isinstance(value, (list, dict, set)):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread app/main.py
else:
immutable.append(name)

sorted_variables = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants