Q. Which is a correct way to merge two dictionaries `d1` and `d2` in Python 3.9+?

  • (A) d1 = d1 + d2
  • (B) d1.merge(d2)
  • (C) d1 |= d2
  • (D) merge(d1, d2)
πŸ’¬ Discuss
βœ… Correct Answer: (C) d1 |= d2
Explanation: The `|=` operator merges two dictionaries in Python 3.9 and later.
Explanation by: Mr. Dubey
The `|=` operator merges two dictionaries in Python 3.9 and later.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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