If there is a hyphen -between two alphabets, we have to remove it: Example A-BA should be ABA; and A-B-BAB should be ABBAB; If an alphabet and a number are next to each … About How Add Hyphen In To String In Python . add The map function is used … Home / Codes / python. python add hyphen Edit: Even if you want suffixed '-', then can do like . Python: Replace whitespaces with an underscore and List comprehension along with slicing can be used … In addition as per your assignment you should add "-" in between the variables to add the hyphens. Or your code is too long (try shortening it). It comes with tools to download, install and uninstall hyphenation dictionaries from LibreOffice’s Git repository. Hyphen def replace_runs_of_whitespace_with_hyphen (word): return '-'.join (word.split ()) hyphrases = [replace_runs_of_whitespace_with_hyphen (w) for w in phrases] Or with regex (but this one could result in leading/trailing hyphens): import re re.sub (r'\s+', '-', word) Share. I'm scraping a list but would like to convert the string to permalinks, which have hyphens between each word. Write a JavaScript program which accept a number as input and insert dashes (-) between each two even numbers. py; Some notes: When your run jythonc, by default, the. Since a tuple is basically like an array that is not modifiable, we'll treat it almost the same as a list It was added to Python 2 Next, we used built-in replace string function to replace empty space with a hyphen Next, we used built-in replace string function to replace empty space with a hyphen.