def repl(string):
    numbers = re.finditer('\\d+', string)
for match, char in zip(numbers, 'XYZ'):
    string = string[:match.start()] + char + string[match.end():]
return string
s = set()
result = []
for string in l:
    string = repl(string)
if string in s:
    continue
s.add(string)
result.append(string)
Transform list with regex