#python #tutorial #course
dictionary = a collection of {key:value} pairs
ordered and changeable. No duplicates
capitals = {"USA": "Washington D.C.",
"India": "New Delhi",
"China": "Beijing",
"Russia": "Moscow"}
print(dir(capitals))
print(help(capitals))
print(capitals.get("Japan"))
if capitals.get("Russia"):
print("That capital exists")
else:
print("That capital doesn't exist")
capitals.update({"Germany": "Berlin"})
capitals.update({"USA": "Detroit"})
capitals.pop("China")
capitals.popitem()
capitals.clear()
keys = capitals.keys()
for key in capitals.keys():
print(key)
values = capitals.values()
for value in capitals.values():
print(value)
items = capitals.items()
for key, value in capitals.items():
print(f"{key}: {value}")
On this page of the site you can watch the video online Python dictionaries are easy 📙 with a duration of hours minute second in good quality, which was uploaded by the user Bro Code 10 November 2022, share the link with friends and acquaintances, this video has already been watched 501,862 times on youtube and it was liked by 13 thousand viewers. Enjoy your viewing!