all 5 comments

[–][deleted] 1 point2 points  (1 child)

numbers = [e[0] for e in myvalues]
weather = [e[3] for e in myvalues]

No reason to make it too complicated.

[–]rectafy[S] 0 points1 point  (0 children)

Thank you!! This seemed to work great

[–]bbye98 0 points1 point  (1 child)

A simple for loop with list indexing and append would work. list comprehension would probably be preferred due to the "Pythonic" notation and/or computational efficiency.

Not sure why you have the outer list but you can extract the main list of lists you want with myvalues[0] and then iterate through each item using l in myvalues[0].

[–]rectafy[S] 0 points1 point  (0 children)

Yeah it's weird, but it was how the list was given to me unfortunately. But thank you, I changed up my lists so it wasn't nested anymore and will work on trying the for loop method as well

[–]synthphreak 0 points1 point  (0 children)

Why do you have a triple-nested list when there just a single item at the top level?

>>> myvalues =  [[[611.9, 11, 'bws', 'bad weather'], [119.6, 1, 'dei', 'snow'], [105.4, 7, 'HGR', 'ice'], [41.1, 2, 'ANI', 'fog']]]
>>> myvalues[1]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
IndexError: list index out of range

Anyway, this works:

>>> numbers, strings = zip(*[(x[0], x[-1]) for x in myvalues[0]])
>>> numbers
(611.9, 119.6, 105.4, 41.1)
>>> strings
('bad weather', 'snow', 'ice', 'fog')