File tree 1 file changed +28
-8
lines changed
1 file changed +28
-8
lines changed Original file line number Diff line number Diff line change 52
52
finalOp = {}
53
53
54
54
def needOutput (sub , professors ):
55
- finalOp = dict (zip (sub , professors ))
56
- for i in sub :
57
- if i in finalOp :
58
- pass
59
- else :
60
- finalOp [i ] = None
61
- return finalOp
55
+ if len (sub ) > len (professors ):
56
+ finalOp = dict (zip (sub , professors ))
57
+ finalOp = includedMissedEleement (finalOp , sub )
58
+ return finalOp
59
+ elif len (professors ) > len (sub ):
60
+ finalOp = dict (zip (professors , sub ))
61
+ finalOp = includedMissedEleement (finalOp , professors )
62
+ return finalOp
63
+ else :
64
+ return dict (zip (sub , professors ))
65
+
66
+
67
+ def includedMissedEleement (op , listToCheck ):
68
+ for i in listToCheck :
69
+ if i not in op :
70
+ op [i ] = None
71
+ return op
62
72
63
73
desiredOutput = needOutput (subject , teachernames )
64
- print (desiredOutput )
74
+ print (desiredOutput )
75
+
76
+ # the above output is desired only in case of more subjects than teachers.
77
+
78
+ # what if there're more teachers than subjects.
79
+
80
+ subject = ['Tamil' , 'English' ]
81
+ teacherNames = ['Ram' , 'Tamanna' , 'Lita' ]
82
+
83
+ finaOutput = needOutput (subject , teacherNames )
84
+ print (finaOutput )
You can’t perform that action at this time.
0 commit comments