Python: How do u organize a list based on its first element without hardcoding it?
Kavin1983 (1)

How would you organize a list of list based on its first element without hardcoding the list length or the value of the element?

ex:

my_list = [[28,34,6], [28,23,5], [29,78,4], [29,56,4],[30,23,6],[30,34,4]]

list_for28 = [elements that have the 0th value of 28]
list_for29 = [elements that have the 0th value of 29]
list_for30 = [elements that have the 0th value of 30]

i've been dealing with this problem for quite a while and not hardcoding it is very difficult for me.

You are viewing a single comment. View All
Kavin1983 (1)

@OldWizard209 thanks but the thing is I’m using a api and the 0th value will be changing every day.