We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Strings
- String Split and Join
- Discussions
String Split and Join
String Split and Join
Sort by
recency
|
1076 Discussions
|
Please Login in order to post a comment
def split_and_join(line): s_line=line.split(" ") j_line="-".join(s_line)
we can use this two methods adn make the code short and easy
def split_and_join(line): # write your code here a=line.split() a='-'.join(a) return a if name == 'main': line = input() result = split_and_join(line) print(result)
For Python3
as i came with another way, i let you know...
def split_and_join(line): l=line.split() return '-'.join(l)
if name == 'main': line = input() result = split_and_join(line) print(result)