Join Words with Dash
Python
Easy
2 views
Problem Description
A sentence line is provided with words separated by spaces. Join words using '-' and output.
Input Format
One line sentence.
Output Format
One line joined.
Official Solution
import sys
s=sys.stdin.read()
if s is None: sys.exit(0)
if s.endswith('\
'):
s=s[:-1]
words=[w for w in s.split(' ') if w!='']
sys.stdout.write('-'.join(words))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!