# Python3 code to remove whitespace def remove(string): return string.replace(" ", "") # Driver Program string = ' g e e k ' print(remove(string))
s = ' Hello World From Pankaj \t\n\r\t Hi There ' >>> s.replace(" ", "") 'HelloWorldFromPankaj\t\n\r\tHiThere'
string=' t e s t ' print(string.replace(' ',''))
sentence = ' hello apple' sentence.strip() >>> 'hello apple'
## Remove the Starting Spaces in Python string1=" This is Test String to strip leading space" print (string1.lstrip())
>>> import re >>> re.sub(' +', ' ', 'The quick brown fox') 'The quick brown fox'
sentence = ' hello apple ' sentence.strip() >>> 'hello apple'
>>> s.replace(" ", "")