Python Dictionary get() Method

0
7Кб

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
Поиск
Категории
Больше
Science Fiction and Fantasy
Star Wars: Episode V - The Empire Strikes Back. (1980)
After the Rebels are brutally overpowered by the Empire on the ice planet Hoth, Luke Skywalker...
От Leonard Pokrovski 2022-11-13 20:22:35 0 19Кб
Programming
Lua vs JavaScript
Sr. No Lua JavaScript 1 Lua is one of the cross-platform programming languages...
От Jesse Thomas 2023-06-07 21:31:08 0 7Кб
Business
What is the Difference Between a Resume and a Business Biography?
In the professional world, both resumes and business biographies serve as tools to present an...
От Dacey Rankins 2025-01-07 14:17:27 0 6Кб
Social Issues
The Cove (2009)
Using state-of-the-art equipment, a group of activists, led by renowned dolphin trainer Ric...
От Leonard Pokrovski 2023-07-06 20:33:34 0 21Кб
Business
What are the Tax Implications of Working Remotely?
As the global workforce increasingly shifts to remote work, understanding the tax implications of...
От Dacey Rankins 2025-01-30 15:45:16 0 7Кб
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov