How to wrap text in Python

1 Answer

0 votes
import textwrap

text = "Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python's design philosophy emphasizes code readability with its notable use of significant whitespace."

text = "\n".join(textwrap.wrap(text, 50)) # wrap: 50 characters

print(text);
 
 
 
'''
run:
 
Python is an interpreted, high-level, general-
purpose programming language. Created by Guido van
Rossum and first released in 1991, Python's design
philosophy emphasizes code readability with its
notable use of significant whitespace.
  
'''

 



answered Aug 4, 2020 by avibootz

Related questions

1 answer 249 views
249 views asked Aug 4, 2020 by avibootz
1 answer 193 views
2 answers 233 views
1 answer 235 views
...