From 0e5da5a08105ac626778f40f9e65001106e13696 Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Thu, 11 Apr 2024 03:42:33 +0530 Subject: [PATCH 1/4] hello World #1 --- practice/hello-world/hello_world.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/practice/hello-world/hello_world.py b/practice/hello-world/hello_world.py index adaa6c2..d695ea1 100644 --- a/practice/hello-world/hello_world.py +++ b/practice/hello-world/hello_world.py @@ -1,2 +1,2 @@ def hello(): - return 'Goodbye, Mars!' + return 'Hello, World!' From 95931877024fdd8519820db0b0e83f9b8c16a9e0 Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Thu, 11 Apr 2024 23:48:39 +0530 Subject: [PATCH 2/4] Revert "hello World #1" This reverts commit 0e5da5a08105ac626778f40f9e65001106e13696. --- practice/hello-world/hello_world.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/practice/hello-world/hello_world.py b/practice/hello-world/hello_world.py index d695ea1..adaa6c2 100644 --- a/practice/hello-world/hello_world.py +++ b/practice/hello-world/hello_world.py @@ -1,2 +1,2 @@ def hello(): - return 'Hello, World!' + return 'Goodbye, Mars!' From c0242676b43ecaebbd6965190a68ef9ccee8b83f Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Fri, 12 Apr 2024 00:46:06 +0530 Subject: [PATCH 3/4] etl --- practice/etl/etl.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/practice/etl/etl.py b/practice/etl/etl.py index 993dca2..243a5b0 100644 --- a/practice/etl/etl.py +++ b/practice/etl/etl.py @@ -1,2 +1,6 @@ -def transform(legacy_data): - pass +def transform(old): + new = {} + for point, letters in old.items(): + for letter in letters: + new[letter.lower()] = point + return new \ No newline at end of file From 1766db55c23f4023f42055adeabbffbfc2ba6b44 Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Mon, 22 Apr 2024 14:04:53 +0530 Subject: [PATCH 4/4] improved the code --- practice/etl/etl.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/practice/etl/etl.py b/practice/etl/etl.py index 243a5b0..6fc2259 100644 --- a/practice/etl/etl.py +++ b/practice/etl/etl.py @@ -1,6 +1,28 @@ -def transform(old): - new = {} - for point, letters in old.items(): +def transform(old_dict): + """ + Transforms the input dictionary by swapping keys with values. + + The function iterates over each key-value pair in the input dictionary. + Each value is expected to be a list. For each element in the list, a new + key-value pair is added to the output dictionary, where the key is the + element (converted to lowercase) and the value is the original key from + the input dictionary. + + Args: + old_dict (dict): A dictionary to be transformed. Each value should be + a list. + + Returns: + dict: The transformed dictionary. + + Raises: + TypeError: If a value in the input dictionary is not a list. + """ + new_dict = {} + for point, letters in old_dict.items(): + if not isinstance(letters, list): + raise TypeError('Each value in the input dictionary should be a list.') for letter in letters: - new[letter.lower()] = point - return new \ No newline at end of file + # Convert the letter to lowercase and add it to the new dictionary + new_dict[letter.lower()] = point + return new_dict \ No newline at end of file