DS140223 Dict | Set

dict = dict(foo=1, bar=2)
print (dict)
{‘foo’: 1, ‘bar’: 2}

Any questions in this?

the question asks for valid key not valid code for dictionary.
we can use
dict[('foo','bar')] = 30 #some_value
as tuple can be used as a key
but not

dict[dict(foo=1,bar=2)] = 30
dict[['foo','bar']] =30
dict[[['foo','bar']]] = 30

as list, dictionary can not be used as keys

The concept used for this question is:
Dictionary keys are immutable and unique.
Here the correct answer is tuple (‘foo’, ‘bar’), 3d option.

And 2nd & 4th options are mutual type.
1st option shows nested dictionary (dictionary inside dictionary).

Hope this explanation will help.