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

2706 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Which function is ran when an object is instantiated?


Whats the output of "for i in "hello world": print(i)" and why/how is this achieved


How would you write a while loop to print all even numbers from 1-10?


What is the difference between DFS and BFS? Where can I apply each?


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