N-th symbol

Report a typo

Write a program that reads one string and one number N and prints the N-th symbol of the input string. Here the N refers to the position of the symbol not its index. The examples below show how the result should look like.

Input: one string and one number of type Int in separate lines.

Output: single string. Use the following template:

"Symbol # N of the string "input string" is 'character', where N is the input number, input string — the string your read, and character — the N-th symbol of the input string."

Hint

Note, that you can escape characters in strings, through the use of a backslash (\) and a character in a string template. As an example, you can output the symbol " using the \" combination.

Sample Input 1:

hello world
1

Sample Output 1:

Symbol # 1 of the string "hello world" is 'h'

Sample Input 2:

hyperskill
5

Sample Output 2:

Symbol # 5 of the string "hyperskill" is 'r'
Write a program in Kotlin
fun main() {
// write your code here
}
___

Create a free account to access the full topic