how to split a string every n characters python code example

Example 1: python split sentence into words

sentence = 'Hello world a b c'
split_sentence = sentence.split(' ')
print(split_sentence)

Example 2: how ot split a string every fourth eter

>>> line = '1234567890'
>>> n = 2
>>> [line[i:i+n] for i in range(0, len(line), n)]
['12', '34', '56', '78', '90']

Example 3: split a string every character

# Python3 - separate each character of non-spaced string

def split(string): 
	return [letter for letter in string] 
	
# Driver code 
string = 'split this string'
print(split(string))