You are given a string S and width w.
Your task is to wrap the string S into a paragraph of width w.
Input Format
The first line contains a string, S.
The second line contains the width, w.
Sample Input
ABCDEFGHIJKLIMNOQRSTUVWXYZ
4
Sample Output
ABCD
EFGH
IJKL
IMNO
QRST
UVWX
YZ
I tried the code, but didn't get the required result. As 2 extra lines are coming in the output. Also Note: Last 4 lines in the code is immutable(not to be changed)
import textwrap
def wrap(string, max_width):
y=max_width
z=0
for i in range(0,len(string),y):
print(string[0+z:y+z])
z+=max_width
if __name__ == '__main__':
string, max_width = input(), int(input())
result = wrap(string, max_width)
print(result)
S?print(result)deal with the output