Input Format
The first line contains a string consisting of space separated words.
Output Format
Print the formatted string as explained above.
hackerrank string split and join problem solution in python

Problem solution in python 2 programming language.

print "-".join(raw_input().split())

Problem solution in python 3 programming language.

print "-".join(input().split())

Second solution

def split_and_join(line):
    line = line.split(" ")
    line = "-".join(line)
    return line
if __name__ == '__main__':
    line = input()
    result = split_and_join(line)
    print(result)