Fix the code

Report a typo

The code below should print the last character in the string inputString. However, this code contains a certain number of mistakes, and it also throws StringIndexOutOfBoundsException.

Fix the code below so that it prints the last character in the string inputString and doesn't throw an exception.

Sample Input 1:

lorem

Sample Output 1:

m

Sample Input 2:

ipsum

Sample Output 2:

m
Write a program in Kotlin
val lastIndexChar = inputString[inputString.length]
println(lastIndexChar)
___

Create a free account to access the full topic