Reassigning 'Hello' in this nested list to say 'Goodbye'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mcdermottbobby
    New Member
    • Jun 2018
    • 4

    Reassigning 'Hello' in this nested list to say 'Goodbye'

    list3 = [1,2,[3,4,'hello']]

    I know the solution to this is: list3[2][2]='goodbye'

    Why is this the solution? I don't understand why that is the answer and would appreciate an explanation, thank you!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    list3[2] is the third item in the list, which is itself a list of 3 items.

    list3[2][2] is the third item in the list of the third item in the list.
    Last edited by Rabbit; Jun 18 '18, 10:29 PM.

    Comment

    • mcdermottbobby
      New Member
      • Jun 2018
      • 4

      #3
      Thank you! Much clearer now

      Comment

      Working...