1a_dict = {'color': 'blue', 'fruit': 'apple', 'pet': 'dog'}
2for key, value in a_dict.items():
3 print(key, '->', value)
1>>> objects = ['blue', 'apple', 'dog']
2>>> categories = ['color', 'fruit', 'pet']
3>>> a_dict = {key: value for key, value in zip(categories, objects)}
4>>> a_dict
5{'color': 'blue', 'fruit': 'apple', 'pet': 'dog'}
6
1thisdict = {
2 "1": "C language",
3 "2": "Java Language",
4 "4": "Python Language",
5 "3": "C++",
6}
7
8print('\n\n')
9#print 2nd record from dictionary
10
11n=2
12for index, (key, value) in enumerate(thisdict.items()):
13 if index == n:
14 print(key, '::', value)
15 break