I have the following code:
text = input('Enter your text: ')
if len(text) >= 16:
text = text.replace(' ', '\n')
print(f'Your new text is:\n{text}')
If a user inputs blah blah blah blah the user would get the following output:
Your new text is:
blah
blah
blah
blah
I'm just wondering how can I make my code add a new line after the last available space before the 16 characters mark. So the output should end up being:
Your new text is:
blah blah blah
blah
I'm fairly new to python and I feel like I'm missing some sort of method that can get this done.