What is the function of negative index?

Answer Posted / chaitanya

The sequences in python are indexed and it consists of the positive as well as negative numbers. The numbers that are positive uses ‘0’ that is uses as first index and ‘1’ as the second index and the process goes on like that. The index for the negative number starts from ‘-1’ that represents the last index in the sequence and ‘-2’ as the penultimate index and the sequence carries forward like the positive number. The negative index is used to remove any new-line spaces from the string and allow the string to except the last character that is given as S[:-1]. The negative index is also used to show the index to represent the string in correct order.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How python does compile-time and run-time code checking?

522


What will be the output of ['!!welcome!!']*2?

560


What is instance of a class?

484


What is python keyword?

462


What are all important modules in python reuired for a data science ?

453






How is Python used in web development?

483


Is python a pop or oop?

464


Does netflix use python?

449


Is python dictionary a hash table?

418


What is python inheritance?

433


What are the modes to open a file in python?

461


How would you work with numbers other than those in the decimal number system?

486


What is scheduling in threading?

469


How is fail over mechanism works in python?

436


What is the difference between python append () and extend () functions?

488