HackerRank/해커랭크-String Split and Join-python

cosmos·2021년 8월 11일
0
post-thumbnail

문제

풀이

  • in python, a string can be split on a delimiter.
  • task : you are given a string. split the string on a " "(space) delimiter and join using a - hyphen.
  • returns. : the resulting string.
  • input format : the on line contains a string consisting of space separated words.

코드

# HackerRank, String Split and Join, python3
def split_and_join(line):
    # write your code here
    return '-'.join(line.split(' '))
    
if __name__ == '__main__':
    line = input()
    result = split_and_join(line)
    print(result)

결과

출처 && 깃허브

HackerRank
github

0개의 댓글