Text Wrap Hackerrank Solution
If You want Explanation Watch Video:
Sample Input 0
ABCDEFGHIJKLIMNOQRSTUVWXYZ
4
Sample Output 0
ABCD
EFGH
IJKL
IMNO
QRST
UVWX
YZ
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)
Comments
Post a Comment