From 9bf30d5fa3b389f1277bab4bbe48939e5ecfc612 Mon Sep 17 00:00:00 2001 From: Oleksii Churbanov Date: Mon, 16 Dec 2024 17:42:16 +0200 Subject: [PATCH 1/3] implement py-mutable-immutable --- app/main.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index f07695b9..9ef7336e 100644 --- a/app/main.py +++ b/app/main.py @@ -16,4 +16,32 @@ } collection_of_coins = {1, 2, 25} -# write your code here +sorted_variables = {} + + +def mutable_immutable(*args) -> dict: + mutable = [] + immutable = [] + for element in args: + if isinstance(element, (list, set, dict)): + mutable.append(element) + else: + immutable.append(element) + + sorted_variables["mutable"] = mutable + sorted_variables["immutable"] = immutable + + return sorted_variables + + +result = mutable_immutable( + lucky_number, + pi, + one_is_a_prime_number, + name, + my_favourite_films, + profile_info, + marks, + collection_of_coins, +) +print(result) From d23da5fe61d715b9bd8e7923440c2ecd817e4b8d Mon Sep 17 00:00:00 2001 From: Oleksii Churbanov Date: Mon, 16 Dec 2024 17:48:36 +0200 Subject: [PATCH 2/3] implement py-mutable-immutable --- app/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 9ef7336e..8b9f7ff8 100644 --- a/app/main.py +++ b/app/main.py @@ -16,10 +16,9 @@ } collection_of_coins = {1, 2, 25} -sorted_variables = {} - def mutable_immutable(*args) -> dict: + sorted_variables = {} mutable = [] immutable = [] for element in args: From 5e8a7913c10b550c4d51c9b83418562efdc39b4e Mon Sep 17 00:00:00 2001 From: Oleksii Churbanov Date: Mon, 16 Dec 2024 17:53:10 +0200 Subject: [PATCH 3/3] implement py-mutable-immutable update --- app/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 8b9f7ff8..0e7d3244 100644 --- a/app/main.py +++ b/app/main.py @@ -16,9 +16,12 @@ } collection_of_coins = {1, 2, 25} +sorted_variables = {} + def mutable_immutable(*args) -> dict: - sorted_variables = {} + global sorted_variables + sorted_variables = {"mutable": [], "immutable": []} mutable = [] immutable = [] for element in args: