-->
当前位置:首页 > 题库

PROGRAMMING:Subscript exception

Luz5年前 (2021-05-10)题库455
Input a non empty string and an index value, and output the character corresponding to the index value in the string. If an exception is found, output "input subscript error"
###Input format:
Enter a non empty string, and then enter an index value (in Python, it can be a forward index or a reverse index).
###Output format:
The character corresponding to the index value in the output string. If an exception is found (for example, the input index value is too large or too small, which is beyond the index value range of the string; If the input index value is non integer, the output "input subscript error"
###Input example:
Here is a set of inputs. For example:
```in
Hello World
-4
```
###Output example:
The corresponding output is given here. For example:
```out
o
```
###Input example:
Here is a set of inputs. For example:
```in
abcd
four
```
###Output example:
The corresponding output is given here. For example:
```out
Wrong subscript input
```
###Input example:
Here is a set of inputs. For example:
```in
Good
?
```
###Output example:
The corresponding output is given here. For example:
```out
Wrong subscript input
```







answer:If there is no answer, please comment