a_string = "abcde" n = 2 split_strings = [a_string[index : index + n] for index in range(0, len(a_string), n)]
Here is what the above code is Doing:
1. We create a list comprehension that iterates over the indices of a_string.
2. We use the range function to create a list of indices from 0 to the length of a_string, in steps of n.
3. We use the index to slice a_string, and append the result to the list split_strings.