You are viewing a single comment's thread. Return to all comments →
TextWrap library is already being imported so let's go with that instead of manually loop through characters.
import textwrap
def wrap(string, max_width): return textwrap.fill(string, max_width)
if name == 'main': string, max_width = input(), int(input()) result = wrap(string, max_width) print(result)
Seems like cookies are disabled on this browser, please enable them to open this website
Text Wrap
You are viewing a single comment's thread. Return to all comments →
TextWrap library is already being imported so let's go with that instead of manually loop through characters.
import textwrap
def wrap(string, max_width): return textwrap.fill(string, max_width)
if name == 'main': string, max_width = input(), int(input()) result = wrap(string, max_width) print(result)