0

Here's my list :

list = [(a,1,2),(b,3,4),(c,5,6),(d,7,8),(e,9,10)]

I want to fetch the second element of the first three tuples. In this case it would be 1,3,5. Here's what I did :

[item[1] for item in list]

But this would return all the elements, while I only need the first three. How do I do that?

user93804
  • 83
  • 8

1 Answers1

0

If you know the exact number, you can use the range() function:

[list[i][1] for i in range(3)]