In Python, a string can be split on a delimiter.
You are given a string. Split the string on a " " (space) delimiter and join using a - hyphen.
The first line contains a string consisting of space separated words.
Print the formatted string as explained above.
this is a string
this-is-a-string
In [ ]:
def split_and_join(line):
e = line.split(" ")
h = "-".join(e)
return h