movies = [
"The Holy Grail", 1975, "Terry Jones & Terry Gilliam", 91,
["Graham Chapman",
["Michael Palin", "John Cleese", "Terry Gilliam", "Eric Idle", "Terry Jones"]]]

print(movies[4][1][3] = Eric Idle

Could Someone please explain how it counts from the outer loops through the inner loops With the number 4, 1, & 3? Once the first 4 lands on "Graham Chapman", does Graham then count from Graham starting at 0? Thanks for any and all replies.

6 Years
Discussion Span
Last Post by richieking

The 4 means the 5th element (0 indexed) of the main, outside, list. In this case this element is another list. The 1 means the 2nd element in this new list, which again is another list and the 3 means the 4th element in this final list - as you rightly say - Eric Idle.

movies[0] = The Holy Grail
movies[1] = 1975
movies[2] = Terry Jones & Terry Gilliam
movies[3] = 91
movies[4][0] = Graham Chapman
movies[4][1][0] = Michael Palin
movies[4][1][1] = John Cleese
movies[4][1][2] = Terry Gilliam
movies[4][1][3] = Eric Idle
movies[4][1][4] = Terry Jones


Votes + Comments
well done!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.