Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions substring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Python3 code to demonstrate working of
# Get all substrings of string
# Using list comprehension + string slicing

# initializing string
test_str = "Geeks"

# printing original string
print("The original string is : " + str(test_str))

# Get all substrings of string
# Using list comprehension + string slicing
res = [test_str[i: j] for i in range(len(test_str))
for j in range(i + 1, len(test_str) + 1)]

# printing result
print("All substrings of string are : " + str(res))