Question: I have the following list of words:

```
x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam']

```

I need to remove the words that appear only once, and return there indices, or positions.

```
y = ['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam']

loc = [0, 0, 0, 1, 1, 0, 0]

```

Any simple function to do this?

Answer: 
You can use `Counter` class for exactly this purpose:

```
from collections import Counter

x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam']

c = Counter(x)

new_values = [item for item in x if c[item] > 1]
indexes = [1 if c[item] == 1 else 0 for item in x]

print(new_values)
print(indexes)

```

Output is:

```
['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam']
[0, 0, 0, 1, 1, 0, 0]

```
You can also use list comprehension

```
x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga', 'Lam'] 
y = [name for name in x if x.count(name) != 1]

```

output
======

['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam']