{"id":17305,"date":"2021-08-26T10:42:45","date_gmt":"2021-08-26T05:12:45","guid":{"rendered":"https:\/\/python-programs.com\/?p=17305"},"modified":"2021-11-22T18:37:11","modified_gmt":"2021-11-22T13:07:11","slug":"python-program-to-divide-a-string-in-n-equal-parts","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-divide-a-string-in-n-equal-parts\/","title":{"rendered":"Python Program to Divide a String in ‘N’ Equal Parts"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Check Evil Number or Not<\/a>
\nGiven a string and the task is to divide the given string into “N” equal parts.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given string = \"aaaabbbbccccddddeeee\"<\/pre>\n

Output:<\/strong><\/p>\n

The given string after dividing into 5 equal halves:\r\naaaa\r\nbbbb\r\ncccc\r\ndddd\r\neeee<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given string = \"hellobtechgeeks\"<\/pre>\n

Output:<\/strong><\/p>\n

The given string cannot be divided into 4 equal halves<\/pre>\n

Program to Divide a String in ‘N’ Equal Parts<\/h2>\n

Below are the ways to divide the given string into “N” equal parts.<\/p>\n