From the course: Python Data Structures: Dictionaries

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Python dictionary methods

Python dictionary methods - Python Tutorial

From the course: Python Data Structures: Dictionaries

Start my 1-month free trial

Python dictionary methods

- [Instructor] In this video, we will discuss the basic methods that are useful for unleashing the power of dictionaries. One of the most useful methods to help d.get access the data in the dictionary providing a lot of power to programmers is the get method. The get method provides easy access to the elements of the dictionary. It takes the key as a first parameter. And if the key is not found, the second parameter, a default message key not found is returned. So let's take a look here at this program. In this video lesson, we will continue to use sal_info dictionary, which is the key-value pair collection of the major cities in the US and the average salaries of the software engineers. In line four, I have written print sal_info.get, Dallas as the key. A quick scan at the dictionary shows us that Dallas is a key that's there. So we expect the corresponding value to be returned. In line five, I have .get Portland…

Contents