-1

I want to remove any extra whitespace in a sentece how can i do this with python? for ex :

("  hello   world") >>>  ("hello world")

1 Answers1

0
str = " hello     world "
str_clean = ' '.join(str.split())
print(str_clean)

hello world

Edited, I think I overlooked your initial text.

inverzeio
  • 525
  • 2
  • 10