Answer Posted / chaitanya
Python arrays & list items can be accessed with positive or negative numbers (also known as index).
For instance our array/list is of size n, then for positive index 0 is the first index, 1 second, last index will be n-1. For negative index, -n is the first index, -(n-1) second, last negative index will be – 1.
A negative index accesses elements from the end of the list counting backwards.
An example to show negative index in python
>>> import array
>>> a= [1, 2, 3]
>>> print a[-3]
1
>>> print a[-2]
2
>>> print a[-1]
3
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is set when we have to use?
What does the __ init__ function do in python?
What is the best python interpreter?
What are the python types?
Is del the same as remove()? What are they?
What is loop and types?
Explain about zip() in python?
Do lists start at 0 or 1 java?
Does python support multiple inheritance?
What is memory management in python?
What is whitespace in python?
What is dogpile mechanism? Explain.
Is yield a keyword in python?
How are the functions help() and dir() different?
How to write a text from from another text file in python ?