Notes

Source: 📖 Problem Solving with Algorithms and Data Structures using Python 6.5.3

Date: 2021-11-03


Operations of a map datatype

  • put(key, val) adds a new key/value pair to the map. If the key already exists in the map, then its value is replaced with the newly supplied value.
  • get(key) retrieves the value associated with the supplied key, or None if the key does not exist.
  • del deletes a key/value pair from the map using the syntax del my_map[key].
  • len() returns the length of the map, i.e. the number of key/value pairs.
  • in returns True if a given key exists in the map, or False otherwise. The syntax used is key in my_map.

See also: