Q. Which of the following will raise a TypeError?

  • (A) my_dict = {[1, 2]: 'value'}
  • (B) my_dict = {1: 'value'}
  • (C) my_dict = {True: 'yes'}
  • (D) my_dict = {(1, 2): 'tuple'}
πŸ’¬ Discuss
βœ… Correct Answer: (A) my_dict = {[1, 2]: 'value'}
Explanation: Lists are mutable and cannot be used as dictionary keys, causing a `TypeError`.
Explanation by: Mr. Dubey
Lists are mutable and cannot be used as dictionary keys, causing a `TypeError`.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
55
Total Visits
πŸ“½οΈ
12 mo ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
84%
Success Rate