Skip to content

Add sorting of variables by type#3536

Open
naderidkeidek-star wants to merge 2 commits into
mate-academy:masterfrom
naderidkeidek-star:patch-3
Open

Add sorting of variables by type#3536
naderidkeidek-star wants to merge 2 commits into
mate-academy:masterfrom
naderidkeidek-star:patch-3

Conversation

@naderidkeidek-star
Copy link
Copy Markdown

Try 4. Sort variables into mutable and immutable categories.

Try 4. Sort variables into mutable and immutable categories.
Copy link
Copy Markdown
Author

@naderidkeidek-star naderidkeidek-star left a comment

Choose a reason for hiding this comment

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

please review

Copy link
Copy Markdown
Author

@naderidkeidek-star naderidkeidek-star left a comment

Choose a reason for hiding this comment

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

please review again (this is a test)

5th Try 
# Create dictionary
sorted_variables = {
    "mutable": [],
    "immutable": []
}

# Put variables into a list
variables = {"alucky_number": lucky_number, "pi": pi, "one_is_a_prime_number": one_is_a_prime_number, "cname": name, "my_favourite_films": my_favourite_films, "profile_info": profile_info, "marks": marks, "collection_of_coins": collection_of_coins}

# Check each variable type
for name, value in variables.items():
    if type(value) in [list, dict, set]:
        sorted_variables["mutable"].append(name)
    else:
        sorted_variables["immutable"].append(name)

print(sorted_variables)
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.

1 participant