Python Forum
negative indices in lists
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
negative indices in lists
#3
the negative index in your case goes from -4 to -1. To encompass the whole list it would have to go to zero. However you cannot do this with negative indexes. The way to display this would be:

spam[-4:]

It is easier to use the positive indexes.

John
Reply


Messages In This Thread
negative indices in lists - by Ironword - Sep-13-2019, 01:02 AM
RE: negative indices in lists - by Ironword - Sep-13-2019, 02:12 AM
RE: negative indices in lists - by jsira2003 - Sep-13-2019, 02:19 AM
RE: negative indices in lists - by Ironword - Sep-13-2019, 06:18 AM
RE: negative indices in lists - by perfringo - Sep-13-2019, 07:22 AM
RE: negative indices in lists - by Ironword - Oct-11-2019, 08:37 AM
RE: negative indices in lists - by perfringo - Jan-08-2020, 01:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Positive and negative numbers in a row peterp 1 1,798 Oct-29-2020, 02:42 AM
Last Post: deanhystad
  insert() but with negative index naughtysensei 1 2,457 Oct-01-2020, 03:05 AM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020