Python Dictionary get() Method
نشر بتاريخ 2023-03-07 22:06:39
0
12كيلو بايت
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
البحث
الأقسام
- Arts
- Business
- Computers
- الألعاب
- Health
- الرئيسية
- Kids and Teens
- مال
- News
- Recreation
- Reference
- Regional
- Science
- Shopping
- Society
- Sports
- Бизнес
- Деньги
- Дом
- Досуг
- Здоровье
- Игры
- Искусство
- Источники информации
- Компьютеры
- Наука
- Новости и СМИ
- Общество
- Покупки
- Спорт
- Страны и регионы
- World
إقرأ المزيد
How to establish an emergency savings fund
Establishing an emergency savings fund now can have a big payoff later. Setting aside emergency...
What Role Does Company Culture Play in Team Motivation?
Company culture is more than just a buzzword—it’s the foundation that shapes how...
JavaScript JSON.stringify()
A common use of JSON is to exchange data to/from a web server. When sending data to a web...
Beyond GDP: other ways to measure the economy
Key points
Gross national product, or GNP, includes what is produced...
ADHD: Medication - Stimulants
Methylphenidate and amphetamine or its derivatives are first-line treatments for ADHD as they are...