
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python program for permutation of a given string inbuilt function in python
String is given. Our task is to display permutation of given string. Heresolve this problem in python using inbuilt function permutations (iterable).
Examples
Input: string = 'XYZ' Output: XYZ XZY YXZ YZX ZXY ZYX
Algorithm
Step 1: given string. Step 2: Get all permutations of a string. Step 3: print all permutations.
Example Code
from itertools import permutations def allPermutations(str1): # Get all permutations of string 'ABC' per = permutations(str1) # print all permutations print("Permutation Of this String ::>") for i in list(per): print (''.join(i)) # Driver program if __name__ == "__main__": str1 = input("Enter the string ::>") allPermutations(str1)
Output
Enter the string ::> abc Permutation Of this String ::> abc acb bac bca cab cba
- Related Articles
- Python program for the permutation of a given string inbuilt function in python
- Permutation of a given string using the inbuilt function in Python
- Python Program for BogoSort or Permutation Sort
- Inbuilt Data Structures in Python
- Python program to Count words in a given string?
- Program to find a good string from a given string in Python
- Program to find number of elements in all permutation which are following given conditions in Python
- Python Program to print all permutations of a given string
- Program to find decode XORed permutation in Python
- Python program to change character of a string using given index
- Next Permutation in Python
- Generate all permutation of a set in Python?
- Program to find maximum sum obtained of any permutation in Python
- Program to remove duplicate characters from a given string in Python
- Python program to count number of vowels using set in a given string

Advertisements