human
Count of distinct permutations of every possible length of given string | Function to find the factorial of a number.
Loop to find the factorial of the given number.
Function to find the number of permutations possible for a given string.
Function to find the total number of combinations possible.
Driver Code"
How can the above be solved in Python?

Give me a code to count of distinct permutations of every possible length of given string and the other steps required?
assistant
#Here is code to count of distinct permutations of every possible length of given string and the other steps required.
 def fact ( a ) :
	f = 1
	for i in range ( 2 , a + 1 ) :
		f = f * i
	return f
def permute ( n , r ) :
	ans = 0
	ans = fact ( n ) // fact ( n - r )
	return ans
def findPermutations ( n ) :
	sum = 0
	for r in range ( 1 , n + 1 ) :
		P = permute ( n , r )
		sum = sum + P
	return sum
str = " xz "
n = len ( str )
print ( findPermutations ( n ) )