Q. What is indexing in context to Python strings? Why is it also called two-way indexing?


Answer =

In Python strings, each individual character is given a location number, called index and this process is called indexing. Python allocates indices in two directions:

* in forward direction, the indexes are numbered as 0, 1, 2 ... length-1.
* in backward direction, the indexes are numbered as -1, -2, -3.... length.

This is known as two-way indexing.

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. what about the answer for the second part of question that why it is called two way indexing
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post