HackerRank Program on String Split and Join

--

link : https://www.hackerrank.com/challenges/python-string-split-and-join/problem?isFullScreen=true

Explanation :

The given string is : ‘ this is a string ’

So the task is Split the string on a “ ” (space) delimiter and join using a - hyphen. For that we use split() and join() python string built-in function.

def split_and_join(line):
# write your code here
string=line.split(" ")
stringjoin= "-".join(string)
return stringjoin

if __name__ == '__main__':
line = input()
result = split_and_join(line)
print(result)

This is how we use split() and join() function in program and for we will get the output as below:

Output → ‘this-is-a-string’

After executing program HackerRank gives result whether the solved program is executed successfully or not

Thank you:)

#VevCodeLab

http://vevcodelab.com/

--

--