String Split and Join - HackerRank Python String Problem Solution. Split the given string on a " "
(space) delimiter and join the string using a -
hyphen. Click here to see the problem.
Code:
def split_and_join(line):
str_arr = line.split(" ")
return "-".join(str_arr)
if __name__ == '__main__':
line = input()
result = split_and_join(line)
print(result)
Sample Input
Hello Word
Sample Output
Hello-World