Get All Substrings Of A String In Python

No built-in function only algorithm

Amir Ali Hashemi

--

The algorithm

Let’s say you want to find all possible substrings of a BANANA in Python. Hopefully, there is no built-in function for this, and we have to use our brains to develop an algorithm for it.

One way to achieve this is by setting two pointers, i at the beginning and j at the end of the string. We start off by…

--

--

Amir Ali Hashemi

I'm an AI student who attempts to find simple explanations for questions and share them with others