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.

Recommended Answers

All 2 Replies

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

HTH

commented: well done! +1

well said ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.