For this Question: A ​ permutation is simply a name for a reordering. So the permutations of the string
‘abc’ are ‘abc’, ‘acb’, ‘bac’, ‘bca’, ‘cab’, and ‘cba’. Note that a sequence is a
permutation of itself (the trivial permutation). For this problem, you’ll need
to write a ​ recursive​ function ​​ that takes a string and returns a
list of all its permutations.
A couple of notes on the requirements:
1. The order of the returned permutations must be lexicographically.
2. Avoid returning duplicates in your final list.Input contains a single string S.

Constraints:-
1<=|S|<=8Print all the permutations of string S in lexicographical order.Sample Input: 
ABC

Sample Output :
ABC ACB BAC BCA CAB CBA

Explanation:
all permutation are arranged in lexicographical order .

Sample Input:
(T(

Sample Output:-
((T (T( T((, I have written this Solution Code: def sol(arr):
    dict = {}
    for i in arr:
        if i in dict.keys():
            dict[i] = dict[i] + 1
        else:
            dict[i] = 1

    keys = sorted(dict)
    str = []
    c = []
    s=0
    for key in keys:
        str.append(key)
        c.append(dict[key])
    total = [0]*len(arr)
    sol2(str, c, total, s)

def sol2(str, c, total, s):
    if s == len(total):
        str1=''
        k=str1.join(total)
        print(k,end=' ')

        return

    for i in range(len(str)):
        if c[i] == 0:
            continue
        total[s] = str[i]
        c[i] -= 1
        sol2(str, c, total, s + 1)
        c[i] += 1
str2=input()
n = list(str2)
sol(n), In this Programming Language: Python, Now tell me if this Code is compilable or not?