Home / Python / Anagram Generator in python

Anagram Generator in python

Here is a python program for anagram generator in python language. Read here to know about what is an anagram

def anagram(s):
    n=len(s)
    if n == 1:
        return s
    sb=[]
    for i in range(n):
        sb.append(s[i])
        rval=anagram(s[0:i]+s[i+1:n])
        if isinstance(rval,str):
            sb[i]=sb[i]+rval
        if isinstance(rval,list):
            c=sb[i]
            sb[i]=[c language="+rval[x"][/c] for x in range(len(rval))]

    if(n==2):
        return sb
    else:
        c=[sb[x][h] for x in range(len(sb)) for h in range(len(sb[x]))]
        return c

s=anagram(input("Enter String: "))
print(s)
print("Total String",format(len(s)))

OUTPUT:

python program for anagram generator
anagram generator in python

Tags: anagram generator program in python, anagram solver in python.

One comment

  1. Great work Admin. I dont know that program would be that simple.

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.