[['1', '2', '0'], ['1', '2', '2'], ['1', '2', '5'], ['1', '2', '6']]
I have a list of list as shown above, and I want to set variables and get the value of 3rd index from each list into the variable. What's the most efficient way to set it automatically?
I can have something like
list1=0
list2=0
list3=0
list4=0
for i in s:
list1 = i[2]
But in this scenario, I'm specifying the list1,2,3,4. I want it to increment up and just get 3rd index data into it.
For instance, For the list of lists above, I want to set list1, list2, list3, list4..
Then
list1 = '0'
list2 = '2'
list3 = '5'
list4 = '6'
Rather than me specifiyng list1,list2,list3,list4, what's best method to list and set variables and values on its own from the list of list?
List of list could be changing in size. It could be more than 4 lists in there.