Python Dictionary get() Method
Posted 2023-03-07 22:06:39
0
4K
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
Căutare
Categorii
- Arts
- Business
- Computers
- Jocuri
- Health
- Home
- Kids and Teens
- Money
- News
- Recreation
- Reference
- Regional
- Science
- Shopping
- Society
- Sports
- Бизнес
- Деньги
- Дом
- Досуг
- Здоровье
- Игры
- Искусство
- Источники информации
- Компьютеры
- Наука
- Новости и СМИ
- Общество
- Покупки
- Спорт
- Страны и регионы
- World
Citeste mai mult
Quotes from great people
We all patiently count down the last days until spring arrives. But it is better to spend this...
The Evolution of Comics: From Print to Digital and Beyond
Introduction
Comics have long been a beloved medium for storytelling, offering a unique blend of...
Navigating the Chambers: The Importance of References in Parliamentary Procedure
Navigating the Chambers: The Importance of References in Parliamentary Procedure
Parliamentary...
1917. (2019)
6 апреля 1917 года, разгар Первой мировой войны, Западный фронт на севере Франции. Британский...
American Sniper. (2014)
Navy S.E.A.L. sniper Chris Kyle's pinpoint accuracy saves countless lives on the battlefield and...