Hanwool Codes RSS Tag Admin Write Guestbook
2023-02-07 05:45:56

String Split and Join | HackerRank

 

String Split and Join | HackerRank

Use Python's split and join methods on the input string.

www.hackerrank.com

 

Goal

Replace " "(space) into - (hyphen) in string.

 

 

Solution

You can use replace function in string to replace space into hyphen. 

It is very useful function. So, please remember this function!

 

# String Split and Join

def split_and_join(line):
    # write your code here
    split_line = line.replace(' ', '-')
    
    return split_line

if __name__ == '__main__':
    line = input()
    result = split_and_join(line)
    print(result)
Hanwool Codes. Designed by 코딩재개발.