Python Forum
I’m Flat out struggling to understand list indexes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I’m Flat out struggling to understand list indexes
#5
x is a list of 3 elements: [0, 1, [2]]
x[2] is the third element, a list with a single element: [2]
x[2][0] is the first (and only) element from the previous list: 2

So yes, the first element of [2] is the integer "2".

>>> l = [2]
>>> l[0]
2
>>> l.pop(0)
2
Reply


Messages In This Thread
RE: I’m Flat out struggling to understand list indexes - by bowlofred - Jul-17-2020, 07:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Comparing List values to get indexes Edward_ 7 1,193 Jun-09-2023, 04:57 PM
Last Post: deanhystad
  Replace columns indexes reading a XSLX file Larry1888 2 998 Nov-18-2022, 10:16 PM
Last Post: Pedroski55
  Struggling with Juggling JSON Data SamWatt 7 1,907 May-09-2022, 02:49 AM
Last Post: snippsat
  Syntax errors: Struggling to setup enviroment and load packages AH56 5 2,801 Jun-30-2021, 01:01 PM
Last Post: AH56
  Struggling for the past hour to define function and call it back godlyredwall 2 2,234 Oct-29-2020, 02:45 PM
Last Post: deanhystad
  struggling with != statements CallumRoberts2004 2 1,558 Aug-18-2020, 03:01 PM
Last Post: GOTO10
  How to print array indexes? Mark17 6 2,771 Aug-03-2020, 04:26 PM
Last Post: Mark17
  Struggling with nested list gr3yali3n 3 2,334 Jul-09-2020, 05:30 PM
Last Post: DPaul
  Understand list comprehension and draw PUP280 9 4,010 Apr-23-2020, 05:25 PM
Last Post: PUP280
  Struggling to exit this while loop fatherted99 5 2,492 Feb-08-2020, 07:46 PM
Last Post: fatherted99

Forum Jump:

User Panel Messages

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