Python Dictionary get() Method
Posted 2023-03-07 22:06:39
0
12K
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
Exploring Recreation Audio: Enhancing Your Leisure Time with Sound
In today’s fast-paced world, leisure and recreation are essential for maintaining mental...
49 канал прямая трансляция.
«НСК 49» – новосибирский телеканал. Новости, кино, шоу, музыка –...
Goodfellas. (1990)
The story of Henry Hill and his life in the mob, covering his relationship with his wife Karen...
Understanding Wholesale Trade: The Heart of the Supply Chain
Wholesale trade is a critical component of the global economy, acting as a middleman between...
Mad Max: Fury Road. (2015)
In a post-apocalyptic wasteland, a woman rebels against a tyrannical ruler in search for her...