Answers for "after using str[1:-1] how to remove whitespaces in python"

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
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

Python Answers by Framework

Browse Popular Code Answers by Language