from collections import defaultdict
# Define a lista de volares:
lista = [3, 2, 4, 7, 3, 8, 2, 3, 8, 1]
# Define o objeto que armazenará os índices de cada elemento:
keys = defaultdict(list);
# Percorre todos os elementos da lista:
for key, value in enumerate(lista):
# Adiciona o índice do valor na lista de índices:
keys[value].append(key)
# Exibe o resultado:
for value in keys:
if len(keys[value]) > 1:
print(value, keys[value])
ZnJvbSBjb2xsZWN0aW9ucyBpbXBvcnQgZGVmYXVsdGRpY3QKIAojIERlZmluZSBhIGxpc3RhIGRlIHZvbGFyZXM6Cmxpc3RhID0gWzMsIDIsIDQsIDcsIDMsIDgsIDIsIDMsIDgsIDFdCiAKIyBEZWZpbmUgbyBvYmpldG8gcXVlIGFybWF6ZW5hcsOhIG9zIMOtbmRpY2VzIGRlIGNhZGEgZWxlbWVudG86CmtleXMgPSBkZWZhdWx0ZGljdChsaXN0KTsKIAojIFBlcmNvcnJlIHRvZG9zIG9zIGVsZW1lbnRvcyBkYSBsaXN0YToKZm9yIGtleSwgdmFsdWUgaW4gZW51bWVyYXRlKGxpc3RhKToKIAogICAgIyBBZGljaW9uYSBvIMOtbmRpY2UgZG8gdmFsb3IgbmEgbGlzdGEgZGUgw61uZGljZXM6CiAgICBrZXlzW3ZhbHVlXS5hcHBlbmQoa2V5KQogCiMgRXhpYmUgbyByZXN1bHRhZG86CmZvciB2YWx1ZSBpbiBrZXlzOgogICAgaWYgbGVuKGtleXNbdmFsdWVdKSA+IDE6CiAgICAgICAgcHJpbnQodmFsdWUsIGtleXNbdmFsdWVdKQ==