Python | Trim Whitespace From Strings with Strip Function

preview_player
Показать описание
To remove unnecessary starting and trailing spaces and whitespaces around a string we can use the strip function.

The strip function is a versatile function which can take strings as arguments too and get rid of them from a given string on either side.

We also discuss Lstrip and Rstrip which removes the left and the right spaces and characters respectively.
Рекомендации по теме
Комментарии
Автор

Anyone know how to do it with "int" numbers?

mc_sackling
Автор

I have a question..if we want to restore back everything if we do lstrip..then how can we do that??

iamgurpreetkaur
Автор

how to remove spaces in the middle of a string ?
like: sp a c es -> spaces ?

rayenbahroun
Автор

sanitized_message = ''.join([i for i in message if i.isalpha()])

Skibadee