Basically I want to group all the dictionaries from the list message with the same key (name
) in different lists. How should I proceed?
I was thinking about doing some kind of two loops but nothing seems to work.
messages={('name': FLR345, 'latitude': 34.244, 'longitude': -23.564), ('name': FLR33, 'latitude': 34.24432, 'longitude': -24.53),('name': FLR345, 'latitude': 35.244, 'longitude': -26.564), ('name': FLR31, 'latitude': 30.244, 'longitude': -22.564)}
I want something like this
Drone1={('name': FLR345, 'latitude': 34.244, 'longitude': -23.564),'name': FLR345, 'latitude': 35.244, 'longitude': -26.564)}
Drone2={('name': FLR33, 'latitude': 34.24432, 'longitude': -24.53)}
Drone3={('name': FLR31, 'latitude': 30.244, 'longitude': -22.564)}
def split
for i in range(len(messages))
for j in range(len(messages))
if .......
Dronei=....