I want to wrap the string below:
string = 'ABCDEFGHIJKLIMNOQRSTUVWXYZ'
With the max width as 4, for instance I want this output:
I created this function:
def wrap(string, max_width):
i = max_width
while True:
string = string[:i] + '\n' + string[i+1:]
if i >= len(string):
break
return string
if __name__=='__main__':
string = 'ABCDEFGHIJKLIMNOQRSTUVWXYZ'
print(wrap(string, 4))
But the outputs was:
May you help me, please?