From ed5d94461c88525ec3f59687959e9811bd34e023 Mon Sep 17 00:00:00 2001 From: martoff Date: Fri, 6 Mar 2026 13:36:45 +0200 Subject: [PATCH 1/2] Solution --- app/main.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/main.py b/app/main.py index f07695b9b..06d717e33 100644 --- a/app/main.py +++ b/app/main.py @@ -1,7 +1,19 @@ +# mutable variable - list, dictionary, set +# immutable variable - int, float, bool, string, tuple + +# int lucky_number = 777 + +# float pi = 3.14 + +# bool one_is_a_prime_number = False + +# string name = "Richard" + +# list my_favourite_films = [ "The Shawshank Redemption", "The Lord of the Rings: The Return of the King", @@ -9,11 +21,21 @@ "The Good, the Bad and the Ugly", "The Matrix", ] + +# tuple profile_info = ("michel", "michel@gmail.com", "12345678") + +# dictionary marks = { "John": 4, "Sergio": 3, } + +# set collection_of_coins = {1, 2, 25} # write your code here +sorted_variables = { + "mutable": [my_favourite_films, marks, collection_of_coins], + "immutable": [lucky_number, pi, one_is_a_prime_number, name, profile_info], +} From 8c35e66c9dde592cc1638b2d3a3dc0744b9f9017 Mon Sep 17 00:00:00 2001 From: martoff Date: Fri, 6 Mar 2026 14:15:20 +0200 Subject: [PATCH 2/2] Solution --- app/main.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index 06d717e33..1f0d5129b 100644 --- a/app/main.py +++ b/app/main.py @@ -34,8 +34,22 @@ # set collection_of_coins = {1, 2, 25} -# write your code here -sorted_variables = { - "mutable": [my_favourite_films, marks, collection_of_coins], - "immutable": [lucky_number, pi, one_is_a_prime_number, name, profile_info], -} +variables = [ + lucky_number, + pi, + one_is_a_prime_number, + name, + my_favourite_films, + profile_info, + marks, + collection_of_coins, +] +mutable = [] +immutable = [] + +mutable_types = (list, dict, set) + +mutable = [var for var in variables if isinstance(var, mutable_types)] +immutable = [var for var in variables if not isinstance(var, mutable_types)] + +sorted_variables = {"mutable": mutable, "immutable": immutable}