How to remove existing indentation from all of the lines in a given text in Python

1 Answer

0 votes
import textwrap

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

print(text)

text_without_Indentation = textwrap.dedent(text)

print(text_without_Indentation)



'''
run:

Python is an interpreted high-level general-purpose 
    programming language. Its design philosophy emphasizes 
    code readability with its use of significant indentation. 
    
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

Related questions

...