Chrome Extension

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)
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
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?
0 Comments
Join Devsheet Ask a Question