# 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(' ',''))
## Remove the Starting Spaces in Python string1=" This is Test String to strip leading space" print (string1.lstrip())
sentence = ' hello apple ' sentence.strip() >>> 'hello apple'
>>> s.replace(" ", "")
' hello world! '.strip() 'hello world!' ' hello world! '.lstrip() 'hello world! ' ' hello world! '.rstrip() ' hello world!'