I'm trying to find an elegant way to split a python string every nth character, iterating over which character to start with.
For example, suppose I have a string containing the following:
ANDTLGY
I want to split the string into a set of 3 characters looking like this:
['AND','NDT','DTL','TLG','LGY']
how about
this returns
hopefully you can explain to the professor how it works ;)
Simple way is to use string slicing together with list comprehensions: