January 2019
Beginner
318 pages
8h 23m
English
The indent() function is used to add the specified prefix to the beginning of the selected lines in your text.
The syntax for this function is:
textwrap.indent(text, prefix)
Create a indent_example.py script and write the following content in it:
import textwrapstr1 = "Python is an interpreted high-level programming language for general-purpose programming. Created by Guido van Rossum and first released in 1991, \n\nPython has a design philosophy that emphasizes code readability, notably using significant whitespace."w = textwrap.fill(str1, width=30)i = textwrap.indent(w, '*')print(i)
Run the script and you will get the output as follows:
student@ubuntu:~/work$ python3 ...
Read now
Unlock full access