i have a list of lists and want to store some of its values in a separate list. my list of lists is called data
which was parsed from a data file. the data file had headings which labelled what the values underneath it represented.
the headings looked something like this:
fruit, animal, technology, drink, color
the first few elements of data
looks something like this:
[[apple, dog, phone, water, black],
[banana, cat, laptop, milk, pink],
[melon, bird, computer, juice, green]]
i want to group the values by category so that i can sort it. this quite a large list so i would like to iterate through it all with a loop or something but I'm not sure how to.
i want an output similar to this but for all elements within the outer list:
fruits = [apple, banana, melon]
how would i do this?
any help is appreciated as i am new to python, thanks!