---
title: "Discussion on \"15 Easy Ways to Trim a String in Python\" | Hashnode"
description: "Discussion on \"15 Easy Ways to Trim a String in Python\". Learn how to strip / remove spaces, newline, tabs, special characters, line ending, and more!"
url: "https://hashnode.com/posts/python-trim-string/615965aee2f1936f70b27787"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [15 Easy Ways to Trim a String in Python](https://miguendes.me/python-trim-string?utm_source=hashnode&utm_medium=feed)

Learn how to strip / remove spaces, newline, tabs, special characters, line ending, and more!

Oct 3, 2021 · 8 min read · miguendes.me  
Updated Jul 2, 2022  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#tutorial](https://hashnode.com/tag/tutorial)
-   [#python-beginner](https://hashnode.com/tag/python-beginner)

## Written by

[Miguel Brito](https://hashnode.com/@miguendes)

@miguendes · London, UK

  
[View profile](https://hashnode.com/@miguendes)

Machine Learning Software Engineer - Hobbyst Technical Writer - Interested in Software Testing, Best Practices, Scalability, and Python.

AI Software Engineer based in London, UK with 6+ years of professional experience developing and releasing software in different programming languages - Hobbyist Technical Writer - Interested in Software Testing, Best Practices, Scalability, Machine Learning/AI, and Python.

## Responses 5

Markdown supported · ⌘↵ to post

[Gyansetu](https://hashnode.com/@gyansetu)

[Oct 20, 2023](https://hashnode.com/posts/python-trim-string/615965aee2f1936f70b27787/comment/65329e129e28a744a35998ac)

Python | Gyansetu offers outstanding Python programming courses. The instructors are highly skilled, and the practical approach ensures rapid skill development. It's the perfect destination for mastering Python and enhancing your coding prowess! For more info:- [gyansetu.in/blogs/future-scope-of-python-in-india](https://www.gyansetu.in/blogs/future-scope-of-python-in-india/)

[Kelly](https://hashnode.com/@Timmyspinka)

[Oct 3, 2022](https://hashnode.com/posts/python-trim-string/615965aee2f1936f70b27787/comment/633aa3c55af0979a7a8dd13d)

Oh! It's great you have provided so many ways, wordle hint and answer to solve today's Wordle. Thank you,

[Eleftheria Batsou](https://hashnode.com/@eleftheriabatsou)

[Oct 7, 2021](https://hashnode.com/posts/python-trim-string/615965aee2f1936f70b27787/comment/615eb835b945c81a907ce0da)

Oh wow! I certainly didn't know all of them!!

Thank you [Miguel Brito](https://hashnode.com/@miguendes) :)

[Miguel Brito](https://hashnode.com/@miguendes)

[Oct 18, 2021](https://hashnode.com/posts/python-trim-string/615965aee2f1936f70b27787/comment/615eb835b945c81a907ce0da#reply-616d1f3ff1f4c944cc6b2f74)

Thanks [Eleftheria Batsou](https://hashnode.com/@eleftheriabatsou)!

[Chris Bongers](https://hashnode.com/@dailydevtips)

[Oct 4, 2021](https://hashnode.com/posts/python-trim-string/615965aee2f1936f70b27787/comment/615a8ed7e2f1936f70b28f05)

There are actually some ways described that I didn't know about so thanks for writing this down Miguel! ❤️

[Miguel Brito](https://hashnode.com/@miguendes)

[Oct 5, 2021](https://hashnode.com/posts/python-trim-string/615965aee2f1936f70b27787/comment/615a8ed7e2f1936f70b28f05#reply-615c0761ad6beb6f650703ec)

Thanks [Chris Bongers](https://hashnode.com/@dailydevtips), I'm glad to know that, it's always nice when we write a post that shows 'not-so-popular' tricks :)

[Paula Maranhão](https://hashnode.com/@pmaranhaor)

[Oct 3, 2021](https://hashnode.com/posts/python-trim-string/615965aee2f1936f70b27787/comment/615a13bfad6beb6f6506dc13)

15 ways?! I didn’t know that… As a beginner, it would be nice to have more real application examples…if possible.
