My question is similar to this one , but with some changes. First of all, I need to use python and regex. My line: "Four points and seven years ago." and I want to break it into every sixth character, but also, in the end, if the characters are not divisible by 6, I want to return the spaces.
I want to be able to type: 'Four score and seven years ago.'
And ideally, he should output: ['Four s', 'core a', 'nd sev', 'en yea', 'rs ago', '. '] ['Four s', 'core a', 'nd sev', 'en yea', 'rs ago', '. ']
The closest I can get is an attempt that ignores my period and doesn't give me spaces
re.findall('.{%s}'%6,'Four score and seven years ago.')
source share