I have a list 'labels' and a dictionary with key, value pairs 'class_dict'.
I want to loop over my labels list, and print the dictionary key (e.g. 'airplane'), if the class_dict.value() is equal to the label[i].
labels = [2, 7, 1, 0, 3, 2, 0, 5, 1, 6, 3, 4, 2, 9, 3, 8]
class_dict ={'airplane': 0, 'automobile': 1, 'bird': 2,'cat': 3,'deer': 4,'dog': 5,'frog': 6, 'horse': 7,'ship': 8,'truck': 9}
For example
labels[0] = 'bird'
labels[1] = 'ship'
labels[2] = 'automobile'
Essentially I want to do this but in a more concise way:
for i in labels:
for key, val in classes_dict.items():
if val == i:
print(key)