Mark As Completed Discussion

Properties of Dictionaries

  • Dictionaries cannot have duplicate keys. That is, two keys of the same name in the same dictionary will generate an error.
  • Values assigned to keys in a dictionary can be of any data type (as shown in the examples in the previous section).
  • In Python, dictionaries are ordered. This means that they will be sorted in a defined order, and that order cannot change. For example, you cannot move the key-value pair from the first position in the dictionary to the last position.
  • Keys of a dictionary must be immutable. This means that you can use strings, integers, or tuples as dictionary keys, but lists are not allowed.

    In programming, immutable means that the value of a variable cannot be changed over time. Strings, int, and tuples are examples of immutable data types in Python.