From a52f9288aaa541af162ad971690b91d78c5c16c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Egehan=20Hatipo=C4=9Flu?= Date: Sat, 31 Oct 2026 00:47:41 +0300 Subject: [PATCH] Add functions for removing duplicates and counting items --- Week03/sequences_egehan_hatipoglu.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Week03/sequences_egehan_hatipoglu.py diff --git a/Week03/sequences_egehan_hatipoglu.py b/Week03/sequences_egehan_hatipoglu.py new file mode 100644 index 00000000..ef181f2c --- /dev/null +++ b/Week03/sequences_egehan_hatipoglu.py @@ -0,0 +1,20 @@ +def remove_duplicates(seq: list) -> list: + + result = [] + for item in seq: + if item not in result: + result.append(item) + return result + + +def list_counts(seq: list) -> dict: + + counts = {} + for item in seq: + counts[item] = counts.get(item, 0) + 1 + return counts + + +def reverse_dict(d: dict) -> dict: + + return {value: key for key, value in d.items()}