Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to get all distinct substrings in a string python

def substr(string):
    j=1
    a=set()
    while True:
        for i in range(len(string)-j+1):
            a.add(string[i:i+j])
        if j==len(string):
            break
        j+=1
    return a
 
PREVIOUS NEXT
Tagged: #distinct #substrings #string #python
ADD COMMENT
Topic
Name
6+2 =