Feb-10-2021, 09:52 AM
Hello,
I have a question regarding a attribute query I teach myself.
I have three cities:
Now, I did a attribute query, wanting to know, which is the biggest and western most city:
I wanted to know how I can do a query, where I can get the info, what is the most northern city? since I don't know how I can specifically target values inside the POINTS attribute, I wanted to get some help. I thought about making a seperate attribute (POINT1, POINT2) and then perform a query, but since I already have a code which is several hundred lines and has more then a hundred cities in it...yeah.
Secondly, how the hell did my code then work? How did python know, that Durango is the western most city, since the POINT attribute in the city consists of two values.
I hope this is understandably enough, and I'm grateful for any kind of help.
I have a question regarding a attribute query I teach myself.
I have three cities:
NAME = 0 POINTS = 1 POP = 2 cities = [] cities.append(["DENVER", [-104.98, 39.74], 634265]) cities.append(["BOULDER", [-105.27, 40.02], 98889]) cities.append(["DURANGO", [-107.88, 37.28], 17069])As you can see I gave em a name, coordinates(points= longitudinal values, latitude values) and a population-number
Now, I did a attribute query, wanting to know, which is the biggest and western most city:
biggest_city = max(cities, key=lambda city: city[POP]) western_city = min(cities, key=lambda city: city[POINTS])Now to the problem:
I wanted to know how I can do a query, where I can get the info, what is the most northern city? since I don't know how I can specifically target values inside the POINTS attribute, I wanted to get some help. I thought about making a seperate attribute (POINT1, POINT2) and then perform a query, but since I already have a code which is several hundred lines and has more then a hundred cities in it...yeah.
Secondly, how the hell did my code then work? How did python know, that Durango is the western most city, since the POINT attribute in the city consists of two values.
I hope this is understandably enough, and I'm grateful for any kind of help.