Permutations of a Given String || Python
In this we are going to see a basic program to find Permutations of a Given String in Python Programming Language.


def swap(ch, i, j):
    temp = ch[i]
    ch[i] = ch[j]
    ch[j] = temp


def findperm(sl, ind=0):
    if ind == len(sl) - 1:
        print(''.join(sl))

    for i in range(ind, len(sl)):
        swap(sl, ind, i)
        findperm(sl, ind + 1)
        swap(sl, ind, i)


strg = 'ABC'
findperm(list(strg))

#Coded by Saahil

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post