I got this data
employee_detail_list = {
'John Doe': {
'name': 'EMP-0001',
'first_name': 'John',
'last_name': 'Doe',
'full_name': 'John Doe',
'company': 'Company 1'
},
'Tom Smith': {
'name': 'EMP-0002',
'first_name': 'Tom',
'last_name': 'Smith',
'full_name': 'Tom Smith',
'company': 'Company 2'
},
'Andrew Sebastian': {
'name': 'EMP-0003',
'first_name': 'Andrew',
'last_name': 'Sebastian',
'full_name': 'Andrew Sebastian',
'company': 'Company 2'
}, }
i want output
Tom Smith
Andrew Sebastian
by filtering value "Company 2", i've try this code:
# list out keys and values separately
key_list = list(employee_detail_list.keys())
val_list = list(employee_detail_list.values())
# print key with val Company 2
position = val_list.index("Company 2")
print(key_list[position])
but always ended up with this error:
ValueError: 'Company 2' is not in list
any thought what is wrong? thanks before