From 767882206775716f664b6553ba5af549a75e31a1 Mon Sep 17 00:00:00 2001 From: Nader Idkeidek Date: Wed, 20 May 2026 13:00:02 +0300 Subject: [PATCH 1/3] Update main.py 1st try wo VS --- app/main.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index f07695b9b..888f35457 100644 --- a/app/main.py +++ b/app/main.py @@ -16,4 +16,22 @@ } collection_of_coins = {1, 2, 25} -# write your code here +def sort_variables(): + mutable = [] + immutable = [] + + for name, value in globals().items(): + if name.startswith("__"): + continue + + if isinstance(value, (list, dict, set)): + mutable.append(name) + else: + immutable.append(name) + + sorted_variables = { + "mutable": mutable, + "immutable": immutable, + } + + return sorted_variables From 1443ad08fc0f54180bcdd5ac5932bc828e82b1de Mon Sep 17 00:00:00 2001 From: Nader Idkeidek Date: Thu, 21 May 2026 12:51:26 +0300 Subject: [PATCH 2/3] Refactor variable sorting into a dictionary structure 5th again try --- app/main.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/app/main.py b/app/main.py index 888f35457..0011db32e 100644 --- a/app/main.py +++ b/app/main.py @@ -16,22 +16,20 @@ } collection_of_coins = {1, 2, 25} -def sort_variables(): - mutable = [] - immutable = [] - - for name, value in globals().items(): - if name.startswith("__"): - continue +# Create dictionary +sorted_variables = { + "mutable": [], + "immutable": [] +} - if isinstance(value, (list, dict, set)): - mutable.append(name) - else: - immutable.append(name) +# 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} - sorted_variables = { - "mutable": mutable, - "immutable": immutable, - } +# 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) - return sorted_variables +print(sorted_variables) From a474a94673560af10d60309c39a2007fdfbac07e Mon Sep 17 00:00:00 2001 From: Nader Idkeidek Date: Thu, 21 May 2026 13:54:32 +0300 Subject: [PATCH 3/3] Change variables from dict to list and update checks 7th --- app/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index 0011db32e..d93ab8e7e 100644 --- a/app/main.py +++ b/app/main.py @@ -23,13 +23,13 @@ } # 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} +variables = [lucky_number, pi, one_is_a_prime_number, name, my_favourite_films, profile_info, marks, 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) +for variable in variables: + if type(variable) in [list, dict, set,tuple]: + sorted_variables["mutable"].append(variable) else: - sorted_variables["immutable"].append(name) + sorted_variables["immutable"].append(variable) print(sorted_variables)