Python Dictionary get() Method
Postado 2023-03-07 22:06:39
0
12KB
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
- Personal Development
- Recreation
- Regional
- Reference
- Science
- Shopping
- Society
- Sports
- Бизнес
- Деньги
- Дом
- Досуг
- Здоровье
- Игры
- Искусство
- Источники информации
- Компьютеры
- Личное развитие
- Наука
- Новости и СМИ
- Общество
- Покупки
- Спорт
- Страны и регионы
- World
Leia mais
Why Do Growth Rates Mislead?
Growth rates are one of the most common metrics used to describe progress, whether in business,...
Rules of first aid
First aid is the beginning of the treatment of injuries, because it prevents complications such...
Flags
A flag is a piece of fabric (most often rectangular or quadrilateral) with a distinctive design...
Exploring Recreation Audio: Enhancing Your Leisure Time with Sound
In today’s fast-paced world, leisure and recreation are essential for maintaining mental...
What Are the Benefits of Mentoring for the Mentor?
Mentoring is often viewed through the lens of how it benefits the mentee, but the advantages for...