python
Python - String, renove all single character for text
# renove all single character for text
text = "t is a c test for removing multiple spaces"
document =' '.join( [w for w in text.split() if len(w)>1] )
print(document)
Output
is test for removing multiple spaces
This version removes all single chars, and spaces with one space, we have regex version too.
Was this helpful?
Similar Posts
- Python - regex , remove all single characters,replace all single chars,char
- Python - regex,replace all character exept A-Z a-z and numbers
- Get character from a string using index Python
- Python code to get the first character from a string
- Frequency of each character in a Python String
- Convert multiple spaces of a string to single space in python [with and without regex]
- Single line if else condition python