Problem 186580 · easy · Phase 01 Prerequisites & Setup

Stretch the Word

strings · iteration · repetition · join

Given a word s, return a string where the first character appears once, the second twice, the third three times, and so on, with the groups separated by -. Characters keep their original case.

Examples

Input:  s = "abc"
Output: "a-bb-ccc"

Input:  s = "Hi!"
Output: "H-ii-!!!"

Constraints

  • 0 <= len(s) <= 60
  • s may contain letters, digits and punctuation (no spaces)

Goals

  • Repeat a string with `*`
  • Combine pieces with `'-'.join`
  • Use the position of each character
Starting Python…