forked from MIT-Emerging-Talent/ET6-practice-code-review
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Delete solutions/Remove_Duplicates.py"
This reverts commit 3fd6e39.
- Loading branch information
1 parent
5c3c6c0
commit 25ed4d0
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
""" | ||
A module for removing duplicates from a list of numbers | ||
Module contents: | ||
- Remove_Duplicates: Remove any duplicate numbers in the list | ||
Created on 2025-1-4 | ||
@author: Safaa Osman | ||
""" | ||
|
||
|
||
def Remove_Duplicates(items: list) -> list: | ||
""" | ||
This Function Removes any duplicates elements from the list | ||
Arguments: list of elements | ||
Returns: list of elements without duplicates. | ||
Raises: | ||
AssertionError: if the input is not a list | ||
Examples: | ||
>>> Remove_Duplicates(['a','b','a']) | ||
['a', 'b'] | ||
>>> Remove_Duplicates([1,1,2]) | ||
[1, 2] | ||
>>> Remove_Duplicates([1,2,2,3,3,3]) | ||
[1, 2, 3] | ||
>>> Remove_Duplicates([1]) | ||
[1] | ||
>>> Remove_Duplicates([]) | ||
[] | ||
>>> Remove_Duplicates([5,5,5,5,5,5,5]) | ||
[5] | ||
""" | ||
assert isinstance(items, list), "input must be a list" | ||
|
||
Final_list = [] | ||
for item in items: | ||
if item not in Final_list: | ||
Final_list.append(item) | ||
return Final_list |