[Python] Dictionary
This Chapter, we're going to make basic dictionary.
mondict = {
"1": "Janunary",
"2": "February",
"3": "March",
"4": "April"
}
whenever you make dictionary in python, you're going to use open and close curly brackets "{ }"
Let's run
print(mondict["2"])
you get "February"
you can also use "get" function
print(mondict.get("2"))
you can specify default value that I wanna use if the key is not found by using get function.
so when you run this
print(mondict.get("6"))
6 is not on the list, you're going to get "none"
you can also pass the default value to print out
print(mondict.get("6", "invalid value"))
and you're going to get "invalid value"