Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

find all unique substring permutations of a string of a specific length python

import itertools

x = "some string"

# aList contains all permutations of all lengths of string x
aList = [each for eachpermut in [''.join(l) for i in range(len(x)) for l in itertools.combinations(x, i+1)] for each in [''.join(eachpermut) for eachpermut in list(itertools.permutations(eachpermut))]]

# aSet only contains unique permutations of aList of varying lengths
aSet = set(aList))
Comment

PREVIOUS NEXT
Code Example
Python :: pass arguments with apply 
Python :: format date string python 
Python :: map two csv files python 
Python :: matplotlib plot in second axis 
Python :: how to check if a string is lowercase in python 
Python :: global variables python 
Python :: get char of string python 
Python :: urllib.request.urlopen with headers 
Python :: how to download from youtube in discord.py 
Python :: how to create pyw file 
Python :: os.startfile() python 
Python :: most repeated character in a string python 
Python :: Python List count() example 
Python :: compress excel file in python 
Python :: print out session information django 
Python :: django forms error customize 
Python :: if condition in print statement python 
Python :: python do while loop 
Python :: python input for competitive programming 
Python :: colorgram in python 
Python :: python how to print something at a specific place 
Python :: map to list python 
Python :: openpyxl get value from readonly cell 
Python :: python convert list to list of strings 
Python :: download image from url selenium python 
Python :: program to add first and last digit of a number in python 
Python :: download pdf python 
Python :: proper function pandas 
Python :: isnotin python 
Python :: command line arguments in python debugging 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =