In this question, I have to wrap a text according to the given value of width. Everything is going well upto the last part where the program prints "None" in the end.
I tried to make a new list and appending but that did not work out well. Here's the code:
import textwrap
def wrap(string, max_width):
i = max_width
j=0
length = len(string)
while j<length:
word = string[j:i]
i = i+max_width
j = j + max_width
print(word)
string, max_width = input(), int(input())
result = wrap(string, max_width)
print(result)
The aim is to make the proper function. Everything is fine until the program prints "None" in the end.
Sample Input ABCDEFGHIJKLIMNOQRSTUVWXYZ 4
Sample Output
ABCD
EFGH
IJKL
IMNO
QRST
UVWX
YZ
MY OUTPUT:
ABCD
EFGH
IJKL
IMNO
QRST
UVWX
YZ
None