Find the error in following cod.State reason of error
aLst={'a':1, 'b':2, 'c':3}
print (aLst['a' ,'b'])
Answers
The above cod.e will produce KeyError, the reason being that there is no key same as the list ['a' , 'b'] in dictionary aLst.
It seems that the above cod.e intends to print the values of two keys 'a' and 'b', thus we can modify the above cod.e to perform this as:
⟹ aLst={'a':1, 'b':2, 'c':3}
⟹print (aLst['a'] , aLst['b']
Answer:
\huge\fbox\blue{Answer}
Answer
The above cod.e will produce KeyError, the reason being that there is no key same as the list ['a' , 'b'] in dictionary aLst.
It seems that the above cod.e intends to print the values of two keys 'a' and 'b', thus we can modify the above cod.e to perform this as:
⟹ aLst={'a':1, 'b':2, 'c':3}
⟹print (aLst['a'] , aLst['b']
\fbox\red{Now it will give this result as:}
Now it will give this result as:
\green{1\:\:\:2}12