
- 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 the permutation of a given string inbuilt function in python
String is given. Our task is to display permutation of given string. Here solve this problem in python using inbuilt function permutations (iterable).
Example
Input : string = 'XYZ' Output : XYZ XZY YXZ YZX ZXY ZYX
Algorithm
Step 1: given string. Step 2: Get all permutations of 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 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
- Program to reverse the position of each word of a given string in Python
- Python program to count the number of vowels using set in a given string
- Python program to count the number of vowels using sets in a given string
- Python program to change character of a string using given index
- Next Permutation in Python
- Generate all permutation of a set in Python?

Advertisements