Q:

How to do slicing in strings in python?

I am trying to do slicing in string "abcdeeefghij", here I want the slicing in such a way that whatever input I use, i divide the output in the format of a list (such that in one list element no alphabets repeat).
In this case [abcde,e,efghij].
Another example is if input is "aaabcdefghiii". Here the expected output is [a,a,acbdefghi,i,i].
Also amongst the list if I want to find the highest len character i tried the below logic:
max_str = max(len(sub_strings[0]),len(sub_strings[1]),len(sub_strings[2]))
print(max_str)   #output - 6
which will yield 6 as the output, but i presume this logic is not a generic one: Can someone suggest a generic logic to print the length of the maximum string.

A:

Here is how:
s = "abcdeeefghij"

l = ['']

for c in s: # For character in s
    if c in l[-1]: # If the character is already in the last string in l
        l.append('') # Add a new string to l
    l[-1] += c # Add the character to either the last string, either new, or old

print(l)

Output:
['abcde', 'e', 'efghij']

