1 parent 8cf8d6e commit b37ed02Copy full SHA for b37ed02
1 file changed
All_substrings.py
@@ -0,0 +1,31 @@
1
+# Problem Statement
2
+
3
+# For a given input string(str), write a function to print all the possible substrings.
4
5
+# Substring
6
+# A substring is a contiguous sequence of characters within a string.
7
+# Example: "cod" is a substring of "coding". Whereas "cdng" is not as the characters taken are not contiguous
8
9
+# Sample Input 1:
10
+# abc
11
12
+# Sample Output 1:
13
+# a
14
+# ab
15
16
+# b
17
+# bc
18
+# c
19
20
+def subString(s, n):
21
+ # Pick starting point in outer loop
22
+ # and lengths of different strings for
23
+ # a given starting point
24
+ for i in range(n):
25
+ for len in range(i+1,n+1):
26
+ print(s[i: len]);
27
28
+# Driver program to test above function
29
+s = input()
30
+subString(s,len(s));
31
0 commit comments