Skip to content

Commit

Permalink
✨ adding space_cleaner function
Browse files Browse the repository at this point in the history
  • Loading branch information
MaaniBeigy committed Dec 10, 2021
1 parent 9751d47 commit cf9c889
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions python/space_cleaner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Cleaning Spaces."""
# ------------------------ Import libraries and functions ---------------------
import re

# ---------------------------- function definition ----------------------------


def space_cleaner(text: str) -> str:
"""Cleans extra spaces.
Args:
text (str): the text to be cleaned.
Returns:
A text variable of <class 'str'> after separating numbers.
Examples:
>>> space_cleaner("hello to people ")
'hello to people'
"""
clear_text = re.sub(" ", " ", text).strip()
return clear_text

0 comments on commit cf9c889

Please sign in to comment.