Why are negative indexes used?

They are used to access locations from last indexes of any array. So lets say you want to print last two items of an array you will write print(A[-2:]) or if you dont want to display last 3 items of the array you would write print(A[:-3]).

SE
Answered by Samim E. Python tutor

2757 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a short program to print all the even numbers 1 to 100


Write a Python script to take a product name as input and then automatically google search reviews for it and open the top 3 search results in different tabs


How would you get a piece of code to print the numbers 1 to 10


How do you write code to implement a recursive fibonacci algorithm?


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

MyTutor is part of the IXL family of brands:

© 2025 by IXL Learning