Python Dictionaries - tccicomputercoaching.com

Page 1

Python Dictionaries - tccicomputercoaching.com A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values. Let us see how to define access and display dictionary.

Definition: CarDict =

{

"brand": "Ford", "model": "Mustang", "year": 1964 } Here, brand, model and year are keys and ford, Mustang and 1964 are their related values... To access or get particular data from dictionary named CarDict x = CarDict ["model"] print(x) We can change a specific data by referring to its key name: Example CarDict ["year"]=1965


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.