Skip to content

Latest commit

 

History

History
14 lines (9 loc) · 444 Bytes

File metadata and controls

14 lines (9 loc) · 444 Bytes

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

>>> "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