A method also called a hash It is a set of key and value.
The caveat is to use {}.
city = {"Key 1": "Value 1", "Key 2": "Value 2"}
Call by specifying the key.
dic ={"book": "kokugo", "name": "yamada"}
print(dic["book"])
#output: kokugo
Overwrite
dic ={"book": "kokugo", "name": "yamada"}
dic["book"] = "sugaku"
print(dic)
#output: {"book": "suugaku", "name": "yamada"}
add to
dic ={"book": "kokugo", "name": "yamada"}
dic["seibetu"] = "men"
print(dic)
#output: {"book": "kokugo", "name": "yamada", "seibetu": "men"}
Delete
dic = {"book": "kokugo", "name": "yamada", "seibetu": "men"}
del dic["book"]
#Delete the specified element
print(dic)
#output: {"name": "yamada", "seibetu": "men"}
Recommended Posts