Answers for "how to remove white spaces in a string in python"

11

python delete white spaces

sentence = ' hello  apple'
sentence.strip()
>>> 'hello  apple'
Posted by: Guest on May-08-2020
4

remove all whitespace from string python

import re
s = 'n t this is a string   with a lot of whitespacet'
s = re.sub('s+', '', s)
Posted by: Guest on August-03-2020
5

python remove whitespace from start of string

'     hello world!    '.strip()
'hello world!'


'     hello world!    '.lstrip()
'hello world!    '

'     hello world!    '.rstrip()
'    hello world!'
Posted by: Guest on November-24-2020
0

python remove spaces from string

>>> " ".join(s.split())
'Hello World From Pankaj Hi There'
Posted by: Guest on December-14-2020
0

how to strip white space of text in python?

sentence = ' hello  apple'
" ".join(sentence.split())
>>> 'hello apple'
Posted by: Guest on March-26-2021
0

python string remove whitespace

' sss d ssd s'.replace(" ", "")
# output: 'sssdssds'
Posted by: Guest on February-25-2021

Code answers related to "how to remove white spaces in a string in python"

Python Answers by Framework

Browse Popular Code Answers by Language