In this program, we will take a string as input and count a number of non-empty substrings of a given string.
Steps to remove the program
- Take a string as input.
- Count the number of non-empty substrings using the following formula- n*n+1/2 where n is the length of the string.
- Print the output.
#Input string
str1 = "sqatools12"
result = int(len(str1) * (len(str1) + 1) / 2)
#Printing output
print(result)
Output :
55