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
Explain how memcached should not be used in your python project?
What is the use of globals() function in python?
Explain about different blocks in exception handling?
Please explain in python what is slicing?
How do you remove the leading whitespace in a string in python?
Explain different ways to create an empty numpy array in python?
Give an example of shuffle() method?
What is blob in python?
What is *args and **kwargs?
Is python dictionary a hash table?
Tell me what are different methods to copy an object in python?
What is means by call function in python?
Does python support interfaces like in java?
What is the output of this following statement?
What is the best ide for python?