Coding Quiz
This coding quiz challenges you to write a function that returns a specific character from a given string using Python's string indexing feature.
Write a function that, given a string and an index number, returns the character at that position.
Parameter Format
def solution(string, index): return # Write your code here
Constraints
-
The input string can include a variety of characters, such as letters, numbers, special characters, etc.
-
The string is not empty.
-
The given index will be within the range of the string. (Including negative indices)
Example Input and Output
-
Input:
("Hello", 0)
-
Output:
"H"
-
Input:
("Hello, world!", 7)
-
Output:
"w"
-
Input:
("Data Science", -1)
-
Output:
"e"
Guidelines
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help