Find Duplicates in List

Advanced

Find Duplicates in a List

Help! Detective Bugsy is on a mission to find duplicate items in a list. Imagine you have a list of items, and some mischievous clones have snuck in. Your job is to create a special function, find_duplicates, that will help Detective Bugsy identify which items appear more than once!

When you run your function with a list containing duplicates, it should return a new list containing only the items that repeat.

Here's what your function should do:

  1. Take a list of items as input.
  2. Return a new list of items that appear more than once in the input list.
  3. The duplicates list should not have any duplicates itself! Only list each duplicate once.

Examples:

find_duplicates([1, 2, 3, 2, 4, 5, 5]) # Returns [2, 5] because 2 and 5 appear more than once. find_duplicates(['apple', 'banana', 'apple', 'orange', 'banana', 'banana']) # Returns ['apple', 'banana'] because these fruits appear more than once. find_duplicates(["a", "b", "a", "c", "d", "d", "e", "e", "f"]) # Returns ['a', 'd', 'e'] find_duplicates(['cat', 'dog', 'fish']) # Returns [] because no item is repeated.

Are you ready to help Detective Bugsy on this exciting mission? Put on your thinking cap, grab your coding gear, and start finding those mischievous duplicates!

Geek
Inputs

Arg 1:

[1,2,3,2,4,5,5]
Expected Output
[2, 5]
Actual Output
Find Duplicates in List [advanced] | Coding for Kids