Repetitions and templates

Report a typo

Write a program that reads one word and prints it as many times as there are characters in it. Use string templates.

Input: a single string.

Output: a single string. Use the following template:

"N repetitions of the word str: ..."

where N is the number of letters in the entered word, str the inputs word, and instead of ... there should be word repetitions.

Tip: Remember about repeat()!

Sample Input 1:

four

Sample Output 1:

4 repetitions of the word four: fourfourfourfour

Sample Input 2:

seasons

Sample Output 2:

7 repetitions of the word seasons: seasonsseasonsseasonsseasonsseasonsseasonsseasons
Write a program in Kotlin
fun main() {
// write your code here
}
___

Create a free account to access the full topic