Python Dictionary get() Method
Postado 2023-03-07 22:06:39
0
12K
With the built-in get() method, you can get the value from retrieving the specific key. If you put in a key that doesn't exist in the dictionary, it'll raise a KeyError. Here's an example:
car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
x = car.get("model")
print(x)
>> Mustang
Pesquisar
Categorias
- Arts
- Business
- Computers
- Jogos
- Health
- Início
- Kids and Teens
- Money
- News
- Recreation
- Reference
- Regional
- Science
- Shopping
- Society
- Sports
- Бизнес
- Деньги
- Дом
- Досуг
- Здоровье
- Игры
- Искусство
- Источники информации
- Компьютеры
- Наука
- Новости и СМИ
- Общество
- Покупки
- Спорт
- Страны и регионы
- World
Leia Mais
How Often Should I Publish Blog Posts? (A Complete Guide for Beginners and Pros)
If you’ve started a blog or are planning to launch one, you’ve likely asked yourself:...
Interaction with contractors — how to improve work with a programmer
In general, is it worth trying to improve this interaction with developers at all? Why should the...
Why Do I Want to Start a Business?
Starting a business is a big decision—one that involves time, effort, and often a...
How Do I Present Data Effectively?
Data is powerful — but only when people understand it.A chart with too many numbers, a...
To Kill a Mockingbird. (1962)
Atticus Finch, a widowed lawyer in Depression-era Alabama, defends a black man against an...