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
Search
Categories
- Arts
- Business
- Computers
- Games
- Health
- Home
- Kids and Teens
- Money
- News
- Recreation
- Reference
- Regional
- Science
- Shopping
- Society
- Sports
- Бизнес
- Деньги
- Дом
- Досуг
- Здоровье
- Игры
- Искусство
- Источники информации
- Компьютеры
- Наука
- Новости и СМИ
- Общество
- Покупки
- Спорт
- Страны и регионы
- World
Read More
Basics of etiquette in business and everyday communication
Basics of etiquette in business and everyday communicationEtiquette is not just a set of rules...
V for Vendetta. (2005)
In a future British dystopian society, a shadowy freedom fighter, known only by the alias of "V",...
Exploring the World of General Merchandise: A Shopper's Guide
In the vast landscape of retail, general merchandise stores stand as versatile hubs offering a...
Discord.py vs Nextcord
When making a bot on Discord, you've probably ran into 2 libraries that looks really similar. In...
Situational Leadership: The Art of Agile Management for Maximum Efficiency
Situational Leadership: The Art of Agile Management for Maximum Efficiency...