I have a pretty simple coding function that returns all possible substrings of a string including the string itself
def main():
str = raw_input ("Enter first string: ")
size = len(str)
for sub_len in range (1, size + 1):
for idx in range (0, size - sub_len + 1):
sub_str = str[idx : idx + sub_len]
print sub_str
main()
the current output looks like this for the string 'abcd'
a
b
c
d
ab
bc
cd
abc
bcd
abcd
my question is, how can i get the program to print the substrings in the opposite order in terms of length? i.e.:
abcd
abc
bcd
ab
bc
cd
a
b
c
d