Answers for "split a string into N equal parts."

0

split a string into N equal parts.

your_string = [i for i in range(20)]
n= 5
parts = [your_string[i:i+n] for i in range(0, len(your_string), n)]
print(parts)
#[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19],]
Posted by: Guest on May-28-2021

Code answers related to "split a string into N equal parts."

Python Answers by Framework

Browse Popular Code Answers by Language