# Python3 program to print all possible
# substrings of a given string
# Function to print all sub strings
def subString(Str,n):
sub=[]
for l in range(1,n+1):
for i in range(1,l+1):
sub.append(Str[i-1:l])
sub.sort(key=len)
for i in sub:
print(i)
# Driver program to test above function
str1 = ‘muskan’
subString(str1,len(str1))
def substrings(string):
substring=[]
for i in range(len(string)):
for j in range(i+1,len(string)+1):
substring.append(string[i:j])
return list(set(substring))
int main() {
char str[]=”abc”;
int n=3,i,j,k;
for(k=0;k<3;k++){
for(i=k;i<3;i++){
for(j=k;j<=i;j++){
printf("%c",str[j]);
}
printf("\n");
}
}
return 0;
}
# Python3 program to print all possible
# substrings of a given string
# Function to print all sub strings
def subString(Str,n):
sub=[]
for l in range(1,n+1):
for i in range(1,l+1):
sub.append(Str[i-1:l])
sub.sort(key=len)
for i in sub:
print(i)
# Driver program to test above function
str1 = ‘muskan’
subString(str1,len(str1))
def substrings(string):
substring=[]
for i in range(len(string)):
for j in range(i+1,len(string)+1):
substring.append(string[i:j])
return list(set(substring))
string=input()
print(substrings(string))