I´m trying to compare 2 lists in py, then get the values repeat, put it in other list, and then get the index of the value in the very first original list, I got this
cecosXLS = ["0101", "0000", "0111", "0105"]
cecoManizales = ["0000", "0101", "0111", "0501", "0502"]
valoresCausa = ["795000","850000","140000","1450000"]
for x in range(len(cecoManizales)):
comunesManizales = []
temporaList = cecosXLS.copy()
temporaList.sort()
cecoManizales.sort()
for item1, item2 in zip(temporaList, cecoManizales):
if item1 == item2:
comunesManizales.append(item1)
for x in range(len(comunesManizales)):
print(comunesManizales[x])
for x in range(len(comunesManizales)):
comun = comunesManizales[x]
indiceComun = cecosXLS.index(comun)
print(indiceComun)
As you can see, I sort the original list, in a new one, to compare with the list I need to, then assign the values of the occurrences in a new list, the problem here is this:
Very original list = ['0101', '0000', '0111', '0105']
Sort of the original list = ['0000', '0101', '0105', '0111']
List to compare with the original sort = ['0000', '0101', '0111', '0501', '0502']
List of occurrences in both list = ['0000', '0101']
But the total occurrences are 3 instead of 2, '0000', '0101', '0111' but I can reach the last one, because is not in the same index in both of the sort list, how can I do this?