import os def int2set(array): out1 = [] out2 = "" for i in range(len(array)): if array[i] not in out1: out1.append(array[i]) for i in range(len(out1)-1 , -1 , -1): if i == len(out1)-1 and out1[i] == '0' : continue else: out2 = out2 + str(out1[i]) return out2 s = list("98766730") a = int2set(array = s) print (a)