Repeat With Dash
Python
Easy
3 views
Problem Description
Word w and integer n are provided. Output w repeated n times, joined with '-' (dash). If n is 0 output empty.
Input Format
One line: w n.
Output Format
One line string.
Official Solution
import sys
p=sys.stdin.read().strip().split()
if not p: sys.exit(0)
w=p[0]
n=int(p[1])
if n<=0:
sys.stdout.write('')
else:
sys.stdout.write('-'.join([w]*n))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!