Python Dictionary get() Method
Postado 2023-03-07 22:06:39
0
4KB
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
Sisters on Track (2021)
A coming of age story about hope, belonging, and the metaphorical and literal sisterhood of young...
Ран. Ran. (1985)
Япония, XVI век. Стареющий правитель Хидэтора объявляет о разделе своих владений между тремя...
ADHD: Behavioural therapies
There is good evidence for the use of behavioural therapies in ADHD. They are the recommended...
The Controversy and Legacy of Greyhound Racing: A Closer Look
The Controversy and Legacy of Greyhound Racing: A Closer Look
Greyhound racing has long been a...
The Shawshank Redemption. (1994)
Chronicles the experiences of a formerly successful banker as a prisoner in the gloomy jailhouse...