πŸ“Š Python
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

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