How does only selecting index 0,1,2 get all the poem details?

How does that code work for every index and we have just mentioned "0,1 ,2 " ? codeca

If we assume that highlighted_poems_details is a list of lists, then at each iteration, poem will be a list with three elements, hence indices 0, 1 and 2.

1 Like

Is there a more efficient way to produce this result than appending each list, or is that relatively common syntax?

Practically you’d probably be using something like a slice of the original list and the .extend method of a list which takes a iterable and adds all of them at once to the end of the list.