• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Can I access every nth value, for each list a large list?

Resolved: Can I access every nth value, for each list a large list?

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

Python newbie here! I have a list like this:
list_a = [[a,b,c], [d,e,f]]
And I’m trying to find a way to look at only the nth value in each list within the larger list.
i.e. So both a and d where want the first value in each
I understand I can do this:
  • a -> list_a[0][0]
  • d -> list_a[1][0]

but is there a way I can pull both together to form their own list?
Thanks.

Answer:

Use list comprehension:

If you have better answer, please add a comment about this, thank you!

list python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to compare two text files and and change the sign of the data in powershell?

27/03/2023

Resolved: Java Virtual Machines deleted

27/03/2023

Resolved: PyCharm cannot see my newly compiled .pyc see on import

27/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.