Dictionaries

Rob Mastrodomenico · 2022

Dictionaries in Python are used to contain data in a very specific way as they hold key value pairs. The key to dictionaries is that to access values we need to have a key associated with it. Its important to note that the name of the dictionary is arbitrary. The problem with us using dict is that dict is a builtin function with Python that means it actually does something. This chapter covers error handling and aims to access a key in dictionary that doesn't exist. To remove items, the del method is used, where we pass the dictionary name and key combination to remove that key value pair from the dictionary. The chapter looks at approaches to create dictionaries and explores how to create a set of keys with the same value using the fromkeys method.

Read the paper · More papers on PaperTik