In This problem does not have to do much we just need to use one fucntion from python module textwrap for wrapping and or filling text to specific output this module helps use to align text and putting them you can read more about it python docs. But here is solution what i used you can also use wrap() here that works same as well
Problem: https://www.hackerrank.com/challenges/text-wrap/problem?isFullScreen=true
Code:
import textwrap
def wrap(string, max_width):
return textwrap.fill(string, max_width)
if __name__ == '__main__':
string, max_width = input(), int(input())
result = wrap(string, max_width)
print(result)
Input:
ABCDEFGHIJKLIMNOQRSTUVWXYZ
4
Output:
ABCD
EFGH
IJKL
IMNO
QRST
UVWX
YZ
Please leave the comment as well
