How to add a prefix text to all of the lines in a string with Python

1 Answer

0 votes
import textwrap

s = '''
    Python is an interpreted high-level general-purpose 
    programming language. Its design philosophy emphasizes 
    code readability with its use of significant indentation. 
    '''

text_without_Indentation = textwrap.dedent(s)

result = textwrap.indent(text_without_Indentation, '* ')

print(result)




'''
run:

* Python is an interpreted high-level general-purpose 
* programming language. Its design philosophy emphasizes 
* code readability with its use of significant indentation. 

'''

 



answered Sep 2, 2021 by avibootz
...