Python for MATLAB Users
Justin Kiggins
Product Manager
type(definitions)
dict
print(definitions['aardvark'])
A nocturnal burrowing mammal with long ears, a tubular snout, and a long
extensible tongue, feeding on ants and termites. Aardvarks are native to
Africa and have no close relatives.
# Create a dictionary
dog = {'name': 'Toby', 'breed': 'Basset Hound'}
# Add more key:value pairs
dog['weight (lbs)'] = 552.3
dog['birthdate'] = "2016-06-26"
print(dog)
{'name': 'Toby',
'breed': 'Basset Hound',
'weight (lbs)': 552.3,
'birthdate': '2016-06-26'}
# Update weight value dog['weight (lbs)'] = 52.3
print(dog)
{'name': 'Toby',
'breed': 'Basset Hound',
'weight (lbs)': 52.3,
'birthdate': '2016-06-26'}
dog.pop('birthdate')
print(dog)
{'name': 'Toby',
'breed': 'Basset Hound',
'weight (lbs)': 52.3}
Python for MATLAB Users