clubs:python_club:python_club_dictionary
Home | clubs :: cloud club :: python_club :: 3D-Printing | projects :: Proxmox | Kubernetes | scripting | utilities | games
Table of Contents
Python Club Topics - Dictionaries
Dictionary
- Often shortened to “dict”
- Multiple values under 1 variable name
- Used to store collections of data
- Data stored in key & value pairs
- Ordered ( starting in Python 3.7 )
- Keys CANNOT be duplicated
- Created using curley braces ( eg. { } )
- key pairs CAN be changed
Dictionary Example
- Create a dictionary
my_car = { "brand": "Ford", "model": "Focus", "year": 2010 } print(my_car) print("This brand ==> " + my_car["brand"])
- Use the len() function
my_car = { "brand": "Ford", "model": "Focus", "year": 2010 } print(len(my_car))
- Change the value under a key
my_car = { "brand": "Ford", "model": "Focus", "year": 2010 } my_car['model'] = "Mustang" print(my_car)
clubs/python_club/python_club_dictionary.txt · Last modified: by 127.0.0.1
