Here is a python code to find all possible sub strings in a given string. String is a collection of characters, and we can perform multiple operations on strings like search, merge, delete, compare, etc., 

#Get the string
str = input("Enter String:")
substring = []
#find all possible substrings for a given string
for counter in range (0,len(str)):
    substring.append(str[counter:len(str)])
print(substring)
#find length of similarity strings
length = []
for substr in substring:
    #initialize count 
    count = 0
    index = 0
    #take one character from both the strings
    for ch in str:
        if index < len(substr):
            ch1 = substr[index]
            index+=1
        else:
            length.append(count)
            break
        #if the characters are same then increment counters
        if ch == ch1:
            count+=1
        # if the characters are not same then append count and
        # move to next element in list
        else:
            length.append(count)
            break    
    #If the code didn't break then the two strings may match exactly
    else:
        length.append(count)
'''print(substring)
print(length)'''
print(sum(length))

 

OUTPUT:

Enter String:Welcome to programming9
['Welcome to programming9', 'elcome to programming9', 'lcome to programming9', 'come to programming9', 'ome to programming9', 'me to programming9', 'e to programming9', ' to programming9', 'to programming9', 'o programming9', ' programming9', 'programming9', 'rogramming9', 'ogramming9', 'gramming9', 'ramming9', 'amming9', 'mming9', 'ming9', 'ing9', 'ng9', 'g9', '9']
23