# Remove Trailing Spaces And New Lines From A String

We can use string function `strip` to remove trailing spaces and new lines from a string.

## Example

```python
>>> "Hello World!  ".strip()
'Hello World!'
```

**Note:-** We can also use `rstrip` and `lstrip` to remove spaces/new lines from left or right side of the string accordingly.

***Source:*** [***JournalDev***](https://www.journaldev.com/23625/python-trim-string-rstrip-lstrip-strip)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.devjugal.com/python/remove-trailing-spaces-and-new-lines-from-a-string.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
