string = '1234567890'
n = 2 # every 2 characters
split_string = [string[i:i+n] for i in range(0, len(string), n)]
# split_string = ['12', '34', '56', '78', '90']
list("string") # ["s", "t", "r", "i", "n", "g"]
s = "foobar"
s = list(s)
print(s)
<output: ['f', 'o', 'o', 'b', 'a', 'r']>
txt = "foobar"
print(list(txt)) # ["f", "o", "o", "b", "a", "r"]
a_string = "abcde"
n = 2
split_strings = [a_string[index : index + n] for index in range(0, len(a_string), n)]
def split(word):
return [char for char in word]