Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,20 @@
}
collection_of_coins = {1, 2, 25}

# write your code here
# Create dictionary
sorted_variables = {
"mutable": [],
"immutable": []
}

# Put variables into a list
variables = [lucky_number, pi, one_is_a_prime_number, name, my_favourite_films, profile_info, marks, collection_of_coins]

# Check each variable type
for variable in variables:
if type(variable) in [list, dict, set, tuple]:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tuples are immutable in Python and should NOT be included in this check. According to Python conventions: mutable types are list, dict, set; immutable types are int, float, str, bool, tuple. Change [list, dict, set, tuple] to [list, dict, set] so profile_info is correctly classified as immutable.

sorted_variables["mutable"].append(variable)
else:
sorted_variables["immutable"].append(variable)

print(sorted_variables)
Loading