Program to replace every space in a string with hyphen | Python program for the above approach ; Split by space and converting String to list and ; joining the list and storing in string ; returning thee string ; Driver code
def printHyphen ( string ) : NEW_LINE INDENT lis = list ( string . split ( " ▁ " ) ) NEW_LINE string = ' - ' . join ( lis ) NEW_LINE return string NEW_LINE DEDENT string = " Text ▁ contains ▁ malayalam ▁ and ▁ level ▁ words " NEW_LINE print ( printHyphen ( string ) ) NEW_LINE