Skip to content

Instantly share code, notes, and snippets.

@neeyatlotlikar
Created June 25, 2025 14:25
Show Gist options
  • Save neeyatlotlikar/941c112c70af7ac6f35766873986a066 to your computer and use it in GitHub Desktop.
Save neeyatlotlikar/941c112c70af7ac6f35766873986a066 to your computer and use it in GitHub Desktop.
This python script demonstrates the use of the dedent method provided by textwrap package.
from textwrap import dedent
string = """
Only now,
I'm starting to see the light.
The shadows of doubt,
fading into the night.
"""
print("Original string:")
print(string.strip(), "\n")
print("Dedented string:")
print(dedent(string).strip())
@neeyatlotlikar
Copy link
Author

neeyatlotlikar commented Jun 25, 2025

Output:

Original string:

Only now,
    I'm starting to see the light.
    The shadows of doubt,
    fading into the night. 

Dedented string:

Only now,
I'm starting to see the light.
The shadows of doubt,
fading into the night.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment