python remove blanks from string 1

python remove blanks from string

sentence = ' hello  apple  '
sentence.strip()
>>> 'hello  apple'

Here is what the above code is Doing:
1. We create a variable called sentence and assign it the string ‘ hello apple ‘.
2. We call the strip() method on sentence and assign the result to sentence.
3. We print the value of sentence.

Similar Posts