<jupyter_start><jupyter_text>All the IPython Notebooks in this **Python Examples** series by Dr. <NAME> are available @ **[GitHub](https://github.com/milaan9/90_Python_Examples)**  Python Program to Compute all the Permutation of the StringIn this example, you will learn to compute all the permutation of the string.To understand this example, you should have the knowledge of the following Python programming topics:To understand this example, you should have the knowledge of the following **[Python programming](https://github.com/milaan9/01_Python_Introduction/blob/main/000_Intro_to_Python.ipynb)** topics:* **[Python Strings](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String.ipynb)*** **[Python for Loop](https://github.com/milaan9/03_Python_Flow_Control/blob/main/005_Python_for_Loop.ipynb)**<jupyter_code># Example 1: Using recursion

def get_permutation(string, i=0):

    if i == len(string):   	 
        print("".join(string))

    for j in range(i, len(string)):

        words = [c for c in string]
   
        # swap
        words[i], words[j] = words[j], words[i]
   	 
        get_permutation(words, i + 1)

print(get_permutation('eat'))

'''
>>Output/Runtime Test Cases:
     
eat
eta
aet
ate
tae
tea
None
'''
# Example 2: Using itertools

from itertools import permutations

words = [''.join(p) for p in permutations('care')]

print(words)

'''
>>Output/Runtime Test Cases:
     
['care', 'caer', 'crae', 'crea', 'cear', 'cera', 'acre', 'acer', 'arce', 'arec', 'aecr', 'aerc', 'rcae', 'rcea', 'race', 'raec', 'reca', 'reac', 'ecar', 'ecra', 'eacr', 'earc', 'erca', 'erac']
'''<jupyter_output>['care', 'caer', 'crae', 'crea', 'cear', 'cera', 'acre', 'acer', 'arce', 'arec', 'aecr', 'aerc', 'rcae', 'rcea', 'race', 'raec', 'reca', 'reac', 'ecar', 'ecra', 'eacr', 'earc', 'erca', 'erac']
{'fraction_non_alphanumeric': 0.17704918032786884, 'fraction_numerical': 0.01366120218579235, 'mean_word_length': 4.8498402555910545, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '617161', 'license': 'MIT', 'n_tokens_mistral': 703, 'n_tokens_neox': 649, 'n_words': 178, 'path': '02_Python_Datatypes_examples/035_compute_all_the_permutation_of_the_string.ipynb', 'repo_name': 'peterennis/90_Python_Examples', 'size': '1837'}