if mmax < len(n):
sub_string = []
for i in range(mmin, mmax):
sub_string.append(n[i])
I’m trying to figure out how to get a list of all substrings within a given range of lengths. For example, I have a string of n= 123456789 and I need to get all substrings between mmin and mmax. Let’s define mmin=7 and mmax=9.
How would you loop over the range of 7 to 9 to produce a list of substrings from n with a length that is within the range? The function should be dynamic to handle any range as long as it doesn’t exceed the length of the initial string. I’m expecting substrings with a length of 7,8,9
How to get list of substrings within a range of lengths?