Check Tutorial tab to know how to to solve.  

You are given a string $\mbox{S}$ and width $\boldsymbol{w}$. 

Your task is to wrap the string into a paragraph of width $\boldsymbol{w}$.  

Function Description   

Complete the wrap function in the editor below.  

wrap has the following parameters:   

string string: a long string   
int max_width: the width to wrap to   

Returns   

string: a single string with newline characters ('\n') where the breaks should be   

Input Format

The first line contains a string, $\textit{string}$. 

The second line contains the width, $max_width$.

Constraints

$0<len(string)<1000$  
$0<max_{w}idth<len(string)$

Sample Input 0
ABCDEFGHIJKLIMNOQRSTUVWXYZ
4

Sample Output 0
ABCD
EFGH
IJKL
IMNO
QRST
UVWX
YZ

Difficulty: EASY
Tags: String algorithms

Starter code:

Solutions:
(a, k) = (str(input()), int(input()))
print('\n'.join([a[i * k:(i + 1) * k] for i in range(int(len(a) / k) + 1)]))


import textwrap
line = input()
width = int(input())
print(textwrap.fill(line, width))


import textwrap
S = input()
W = int(input())
print(textwrap.fill(S, W))


import textwrap
s = [input() for _ in range(2)]
print(textwrap.fill(s[0], int(s[1])))


import textwrap
st = str(input())
print(textwrap.fill(st, int(input())))


import textwrap
s = input()
w = int(input())
tw = textwrap.wrap(s, w)
for t in tw:
	print(t)


import textwrap
text = input()
n = int(input())
print(textwrap.fill(text, n))


import textwrap
s = str(input())
print(textwrap.fill(s, int(input())))


import textwrap
str1 = input()
num = int(input())
str2 = list(textwrap.wrap(str1, num))
print(textwrap.fill(str1, num))


from textwrap import *
print(fill(input(), int(input())))


s = input()
w = int(input())
from textwrap import fill
print(fill(s, w))


import textwrap
x = input()
w = int(input())
print(textwrap.fill(x, w))


import textwrap
instring = input()
w = int(input())
print(textwrap.fill(instring, w))


import textwrap
print('\n'.join(textwrap.wrap(input(), int(input()))))


import textwrap
s = input()
print(textwrap.fill(s, int(input())))


s = input()
n = int(input())
import textwrap
print(textwrap.fill(s, n))


import textwrap
s = (input(), int(input()))
print(textwrap.fill(*s))


import textwrap
(s, n) = (input(), int(input()))
print(textwrap.fill(s, n))


import textwrap
S = input()
w = int(input())
lis = textwrap.wrap(S, w)
for val in lis:
	print(val)


import textwrap
line = input().strip()
num = int(input())
newline = textwrap.fill(line, num)
print(newline)


import textwrap
my_str = input()
width = int(input())
print(textwrap.fill(my_str, width))


import textwrap
str = input()
n = int(input())
print(textwrap.fill(str, n))


import textwrap
line = input()
width = int(input())
line = textwrap.fill(line, width)
print(line)


import textwrap
string = input()
number = int(input())
print(textwrap.fill(string, number))


import textwrap
a = input()
b = int(input())
lis = textwrap.wrap(a, b)
for i in lis:
	print(i)


from textwrap import fill
data = input()
num = int(input())
data = fill(data, num)
print(data)


import textwrap
string = input()
length = int(input())
print(textwrap.fill(string, length))


import sys, textwrap
if sys.version_info[0] >= 3:
	raw_input = input
s = raw_input().rstrip()
print(textwrap.fill(s, int(raw_input())))


import textwrap
s = input()
n = int(input())
print(textwrap.fill(s, n))


import textwrap
(S, w) = (input(), int(input()))
print(textwrap.fill(S, w))


import textwrap
(n, m) = (str(input()), int(input()))
print(textwrap.fill(n, m))


from textwrap import fill
s = input()
n = int(input())
print(fill(s, n))


import textwrap
s = input()
i = input()
print(textwrap.fill(s, int(i)))


import textwrap
straw = input()
width = int(input())
print(textwrap.fill(straw, width))


import textwrap
s = input()
i = int(input())
for c in textwrap.wrap(s, i):
	print(c)


import textwrap
s = input()
k = int(input())
print(textwrap.fill(s, k))


import textwrap
s = input()
n = int(input())
for l in textwrap.wrap(s, n):
	print(l)


import textwrap
s = input().strip()
w = int(input().strip())
print(textwrap.fill(s, w))


import textwrap
print(textwrap.fill(input(), int(input())))


from textwrap import fill
print(fill(input(), int(input())))


import textwrap
str = input()
max = int(input())
print(textwrap.fill(str, max))


import textwrap
i = input()
x = int(input())
print(textwrap.fill(i, x))


import textwrap
str = input()
width = int(input())
print(textwrap.fill(str, width))


import textwrap
str = input()
size = int(input())
print(textwrap.fill(str, size))


string = str(input())
width = int(input())
import textwrap
print(textwrap.fill(string, width))


import textwrap
S = input()
w = int(input())
print(textwrap.fill(S, w))


from textwrap import wrap, fill
s = input()
w = int(input())
print(fill(s, w))


import textwrap
string = input()
width = int(input())
print(textwrap.fill(string, width))


import textwrap
st = input()
width = int(input())
print(textwrap.fill(st, width))


s = input()
w = int(input())
chunk = ''
for l in s:
	if len(chunk) == w:
		print(chunk)
		chunk = ''
	chunk += l
print(chunk)


import textwrap
str = input().strip()
n = int(input().strip())
for i in textwrap.wrap(str, n):
	print(i)


import textwrap
s = input()
a = int(input())
print(textwrap.fill(s, a))


a = input()
b = int(input())
import textwrap
print(textwrap.fill(a, b))


from textwrap import *
print(fill(str(input()), int(input())))


import textwrap
S = input()
print(textwrap.fill(S, int(input())))


import textwrap
s = input()
w = int(input().strip())
print(textwrap.fill(s, w))


import textwrap
str = input()
w = int(input())
print(textwrap.fill(str, w))


import textwrap
S = input()
n = int(input())
print(textwrap.fill(S, n))


import textwrap
string = input('')
width = int(input(''))
a = textwrap.fill(string, width)
print(a)


import textwrap
s = input().strip()
print(textwrap.fill(s, int(input())))


import textwrap
w = input()
n = int(input())
print(textwrap.fill(w, n))


import textwrap
s = input()
w = int(input())
print(textwrap.fill(s, w))


string = input()
n = int(input())
import textwrap
print(textwrap.fill(string, n))


import textwrap
(s, w) = (input(), int(input()))
print(textwrap.fill(s, w))


import operator
import textwrap

def read_f(f):
	return f(input())

def read_f_words(f):
	return map(f, input().split())
s = input()
w = read_f(int)
print(textwrap.fill(s, w))


from textwrap import wrap
s = input()
w = int(input())
print('\n'.join(wrap(s, w)))


import textwrap
(text, par_len) = (input(), int(input()))
print(textwrap.fill(text, par_len))


import textwrap
a = input()
b = int(input())
print(textwrap.fill(a, b))


from textwrap import fill
text = input()
width = int(input())
print(fill(text, width))