My goal is to get to find the duplicate characters in a string and to replace those unique and non unique elements with other values and put those other values in another string.
I used a Counter, but this is what I got so far:
from collections import Counter
def duplicate_encode(word):
    word = word
    final_result = ""
    dict_input = Counter(word)
    print(dict_input)
    print(dict_input.items())
    for key in dict_input:
        x = int(dict_input[key])
        print("this is key" + "\t" + key)
        print(x)
        if x == 1:
            final_result += "("
        elif x != 1:
            final_result += ")"
    print("'" + final_result + "'")
duplicate_encode("binaryy")
Output:
'((((()'
For example for "binaryy" the output should be '((((())', not '((((()'.
Also, is there a better way to print a string than doing print("'" + final_result + "'")
 
     
    