Home
About Us
Contact Us
Bookmark
Saved Bookmarks
Current Affairs
General Knowledge
Chemical Engineering
UPSEE
BSNL
ISRO
BITSAT
Amazon
ORACLE
Verbal Ability
→
Python Interview Questions
→
General in Python Interview Questions
→
What are negative indexes and why are they used?
1.
What are negative indexes and why are they used?
Answer»
Negative indexes are the indexes from the
END
of the
LIST
or tuple or string.
Arr[-1]
MEANS
the last
ELEMENT
of array
Arr[]
arr = [1, 2, 3,
4
, 5, 6]#get the last elementprint(arr[-1]) #output 6#get the second last elementprint(arr[-2]) #output 5
Show Answer
Discussion
No Comment Found
Post Comment
Related InterviewSolutions
What are negative indexes and why are they used?
What does *args and **kwargs mean?
Explain split() and join() functions in Python?
Explain how to delete a file in Python?
What are iterators in Python?
How are arguments passed by value or by reference in python?
How Python is interpreted?
What is the difference between .py and .pyc files?
What is the use of help() and dir() functions?
What is PYTHONPATH in Python?
Reply to Comment
×
Name
*
Email
*
Comment
*
Submit Reply
Your experience on this site will be improved by allowing cookies. Read
Cookie Policy
Reject
Allow cookies