You're working with a dictionary where keys are country names and values are their capitals. You want to invert this dictionary. What potential issue might you encounter?

  • No potential issue, dictionaries are always invertible.
  • Potential issue: Overwriting keys if country names are not unique.
  • Potential issue: Overwriting values if capitals are not unique.
  • Potential issue: Python dictionaries cannot be inverted.
When inverting a dictionary, if the values (capitals) are not unique, you may encounter an issue where some values get overwritten. This results in the loss of information, as multiple countries may have the same capital. Inverting dictionaries assumes unique values for keys in the original dictionary.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *