refer to code:
.
def find_duplicates(input_list):
seen = set()
duplicates = set()
for item in input_list:
if item in seen:
duplicates.add(item)
else:
seen.add(item)
return list(duplicates)
input_list = ["apple", "orange", "banana", "apple", "orange", "grape"]
duplicates = find_duplicates(input_list)
print(duplicates)
>>>>>>>>>>>>>>>>>>
['apple', 'orange']
..
Thank you.
๐๐ป♂️
No comments:
Post a Comment