+ 2

Can you please choose the right ones and explain me the choices?

Which of the followings are correct? 1.Dictionaries can have Dictionaries as values. 2.Dictionaries can have List as values. 3.List can have Dictionaries as elements. 4.Dictionaries can have list as keys.

16th May 2020, 7:33 PM
Bhanu Tripathi
Bhanu Tripathi - avatar
5 Réponses
+ 2
dictionaries can have only immutable types as keys, therefore only string, number and tuple can be a key of a dictionary. it can have any data type as values which are lists, dictionaries, sets
16th May 2020, 7:38 PM
Sebastian Pacurar
Sebastian Pacurar - avatar
+ 2
keys must be immutable values can be everything
16th May 2020, 7:38 PM
Oma Falk
Oma Falk - avatar
0
Thanks!!
16th May 2020, 7:40 PM
Bhanu Tripathi
Bhanu Tripathi - avatar
0
Thanks a lot.
16th May 2020, 7:46 PM
Bhanu Tripathi
Bhanu Tripathi - avatar