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
Public Service Loan Forgiveness: a path out of student debt
Do you work for a government or nonprofit organization? Or are you considering that career...
Computer Companies: Key Players in a Digital World
The computer industry has evolved dramatically since its inception, driven by innovation and...
Метрополис. Metropolis. (1927)
Метрополис - город будущего, разделен на две части. Под землей находятся жилища рабочих, над ними...
Startup.com. (2001)
Traces the birth and failure of new media company govWorks.com.
My Link
Exploring the World of Camps: A Journey into Nature, Fun, and Growth
Camps have long been an integral part of childhood and adolescence, providing unforgettable...