I have an array below which consists of repeated strings. I want to find and replace those strings, but each time a match is made I want to change the value of the replace strin
f = ['champ', 'king', 'king', 'mak', 'mak', 'mak']
fields_out = [x + str(f.count(x) - f[i + 1:].count(x)) for i, x in enumerate(f)]
print(fields_out)
>>['champ1', 'king1', 'king2', 'mak1', 'mak2', 'mak3']
or
fields_out = [(x if i == f.index(x) else x + str(f.count(x) - f[i + 1:].count(x))) for i, x in enumerate(f)]
print(fields_out)
>>['champ', 'king', 'king2', 'mak', 'mak2', 'mak3']