9951 explained code solutions for 126 technologies

pythonHow to split string by length

str = "somelongtext"
chunk = 3
list = [ str[i*chunk:i*chunk+chunk] for i in range(0, int(len(str)/chunk)) ]ctrl + c
str =

example string to split


size of the substring to split by


will contain list with resulting substrings

range(0, int(len(str)/chunk))

iterate amount of chunks that can fit in our string


select substring for current chunk