Repeat a Character to Build a Border

Easy ⏱ 8 min 85% acceptance ★★★★★ 4.5
Write make_border(char, width) that returns a string made of char repeated width times, useful for building console-output borders/separators.

Examples

Example 1
Input
char = '*', width = 10
Output
'**********'
Explanation

The * character repeated 10 times.

Example 2
Input
char = '=', width = 5
Output
'====='
Explanation

Repetition via the * operator.

Constraints

  • width >= 0
  • len(char) == 1

Topics

StringsRepetition

Companies

TCSWipro

Hints

Hint 1

Python strings support repetition with the `*` operator: `char * width`.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.