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.
Loading...
Related Quiz
- You are designing a RESTful API for an e-commerce platform. How would you structure the API endpoints to handle CRUD operations for products?
- To check the version of Python installed, one can use the command python _______.
- How would you access the last element of a list stored in a variable named my_list?
- How can you avoid hardcoding the URL in Django templates when using the anchor tag?
- When raising a custom exception, the _______ method gets called to display the error message.