January 2019
Beginner
318 pages
8h 23m
English
The wrap() function is used to wrap an entire paragraph in to a single string. The output will be a list of output lines.
The syntax is textwrap.wrap(text, width):
Now, we will see an example of wrap(). Create a wrap_example.py script and write the following content in it:
import textwrapsample_string = '''Python is an interpreted high-level programming language for general-purpose programming. Created by Guido van Rossum and first released in 1991, Python has a design philosophy that emphasizes code readability, notably using significant whitespace.'''w = textwrap.wrap(text=sample_string, width=30)print(w)
Run the script and ...
Read now
Unlock full access