How do I remove that NONE at the end
import textwrap
def wrap(string, max_width):
l = len(string)
sp = 0
diff = 4
case = True
while case:
print(string[sp:diff],end="\n")
sp = sp + 4
diff = diff + 4
if diff>l:
print(string[sp:])
case = False
if __name__ == '__main__':
string, max_width = input(), int(input())
result = wrap(string, max_width)
print(result)
# cannot modify this part of code
Expected:
ABCD
EFGH
IJKL
MNOP
QRST
UVWX
YZ
MY RESULT:
ABCD
EFGH
IJKL
MNOP
QRST
UVWX
YZ
NONE
your wrap function is printing your results
since there is no return from the function you are getting None
instead of this:
if __name__ == '__main__':
string, max_width = input(), int(input())
result = wrap(string, max_width)
print(result)
do this:
if __name__ == '__main__':
string, max_width = input(), int(input())
wrap(string, max_width)
# result = wrap(string, max_width)
# print(result)
your wrap function is not returning anything so no need to store it's output