Approach 1:
simply use set() function because set() can't have duplicates
list (set())
approach 2: Use inbuilt dictionary
list(dict.fromkeys ())
2 Answers
Approach 1:
simply use set() function because set() can't have duplicates
list (set())
approach 2: Use inbuilt dictionary
list(dict.fromkeys ())
To comment on this, Sign In or Sign Up.
Would you like us to review something? Please describe the problem with this {0} and we will look into it.
Your feedback has been sent to the team and we'll look into it.
def remove_duplicates(input_list):
unique_list = []
count_num = set([])
for num in input_list:
if not count_num or i not in count_num:
unique_list.append(num)
count_num.add(num)
return unique_list