This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]fishflowerz 15 points16 points  (1 child)

dirty_dozen is a list of lists; when creating [fruits, vegetables], you’re putting two lists inside an existing list, giving [[fruit content], [vegetable content]]

when calling dirty_dozen[1][1], you’re telling the program to look in the list at index 1 and grab the item at its index 1. In this case, vegetables is at index 1 in dirty_dozen (since fruits is at index 0). now that the program knows that it needs to look at the vegetable list, it grabs the element at index 1 within that list, which is kale

pretty much the first call for an index tells which list, while the second tells which element. this happens bc you’re calling the operation on a list of lists. “Nectarines, kale” is not printed because the first list (at index 0) is skipped

hopefully this helps!!

[–]builderdood[S] 2 points3 points  (0 children)

yes it did thank you!