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 the purpose of not in operator?
Name few python web frameworks for developing web applications?
How do you append to a file?
How would you generate a random number in python?
What does super () do python?
which standard datatype in python is immutable?
Why do array indexes start with 0 in most languages?
What is a sequence in python?
Which methods/functions do we use to determine the type of instance and inheritance?
Are lambda functions faster python?
Does apple use python?
What is the use of dir() function?
What does != Mean in python 3?
What does split () do in python?
What is zip() function in python?