Can you please tell me if there is a better way to do this?
people = {'123456':{'first': 'Bob', 'last':'Smith'},
'2345343': {'first': 'Jim', 'last': 'Smith'}}
names = list()
first_names= set()
last_names = set()
for device in people:
names.append(device)
first_names.add(people[device]['first'])
last_names.add(people[device]['last'])
I want to get a list of IDs, and sets of first and last Names. I know this code will work, but can I improve this?