# Using Regular Expressions to account for multiple whitespace characters.
import re
def dashes(text):
return re.sub("\s+", "-", text)
# Example
print(dashes("This is awesome ain't It")
# Outputs => "This-is-awesome-ain't-It"
A little helper function useful for url and file-name assembling using the "re" (regex) module.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.