import random
import string
def get_indexes(els):
els_unique = []
for el in els:
if el not in els_unique:
els_unique.append(el)
indexes = {el: i for i, el in enumerate(els_unique)}
return [indexes[k] for k in els]
l = ['abc', 'apple', 'pen', 'abc', 'pen', 'pc']
new_l = random.sample(tuple(random.randint(100, 110) for _ in range(30)), 15)
random.shuffle(new_l)
print(get_indexes(l))
print(new_l, get_indexes(new_l))