KnowledgeBoat Logo

Computer Science

Can you specify an out of bound index when accessing a single character from a string? Why?

Python String Manipulation

13 Likes

Answer

We cannot specify an out of bound index when accessing a single character from a string, it will cause an error. When we use an index, we are accessing a constituent character of the string. If the index is out of bounds there is no character to return from the given index hence Python throws string index out of range error.

Answered By

7 Likes


Related Questions