File tree 1 file changed +34
-0
lines changed 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 57
57
data = bio .get ('interest' ,'no such key-value pair is present' )
58
58
print (data )
59
59
'''
60
+ # Sorting in dictionary
61
+ # Also, Dictionary and list together
62
+
63
+ f = {
64
+ 'bob':'python',
65
+ 'harry':'ruby',
66
+ 'jack':'c',
67
+ 'stan':'java',
68
+ }
69
+
70
+ list1 = ['jack','stan']
71
+ for each in f.keys():
72
+ print(each.title())
73
+
74
+ if each in list1:
75
+ print('hi ' + each.title()+' you said your fav lang is ' +f[each].title()+ '!')
76
+
77
+ note: that in last line the 'each' will work for 'values' as well, just mention it with dictionary name.
78
+ You can also use the keys() method to find out if a particular person was polled.
79
+ means if a person is not present in list we can send a message like,
80
+
81
+ if 'peter' not in f.keys():
82
+ print('Peter please mention your fav language')
83
+
84
+ for every in sorted(f): # sorting in dictionary
85
+ print('Thanks ' + every.title() + ' for taking the poll')
86
+
87
+ output:
88
+ Thanks Bob for taking the poll
89
+ Thanks Harry for taking the poll
90
+ Thanks Jack for taking the poll
91
+ Thanks Stan for taking the poll
92
+
93
+
60
94
61
95
# question 1: Introducion
62
96
'''
You can’t perform that action at this time.
0 commit comments