Q. Find the error/output. Consider below given two sets of codes. Which one will produce an error? Also, predict the output produced by the correct code.
(a)
box = {}
jars = {'Jam' : 4}
crates = {}
box['biscuit'] = 1
box['cake'] = 3
crates['box'] = box
crates['jars'] = jars
print (len(crates[box]))
(b)
box = {}
jars = {'Jam' : 4}
crates = {}
box['biscuit'] = 1
box['cake'] = 3
crates['box'] = box
crates['jars'] = jars
print (len(crates['box']))
Answer =
Output: -
(a) Error in line 8.
(b)
2
>>>
explanation???
ReplyDeleteFirst a part is not correct
ReplyDeleteGive the correct one
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )