What's a negative index?



What's a negative index?..

Answer / Jeetendra Kumar Pandey

In Python, when working with sequences like lists or strings, using a negative number as an index refers to counting from the end of the sequence. For example, `my_list[-1]` gets the last element in the list.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

List of lists changes reflected across sublists unexpectedly?

1 Answers  


Why python is faster than java?

1 Answers  


What is the difference between `del` and `remove()` in Python?

1 Answers  


Is true a keyword in python?

1 Answers  


When would you use a list vs. A tuple vs. A set in python?

1 Answers  


Explain the use of // operator in python?

1 Answers  


What is a means by “tuple in python”?

1 Answers  


How can you get the google cache age of any url or web page?

1 Answers  


Explain static class variables in python?

1 Answers  


What is subn() function?

1 Answers  


What is numpy in python?

1 Answers  


What does the map() function do?

1 Answers  


Categories