Definition
- One of the data structure in python.
- has key and value binded. You can find value when you know the key
- very slimier with hashmap
how to use
dictionary={"key1":"value1","key2":"value2","key3":"value3"}
print(dictionary.get("key3"))
Example
declaration
- use { and } to declare
- the value can be list
- the key can be int or string. But not list. (TypeError: unhashable type: 'list')
dictionary={"key1":"value1","key2":"value2","key3":"value3"}
insert like List
print(dictionary["key1"])
print(dictionary["key2"])
print(dictionary["key3"])
using get()
print(dictionary.get("key1"))
print(dictionary.get("key2"))
print(dictionary.get("key3"))
print(dictionary.get("key4"))