what is dictionary? give an example how to access the element of dictionary
Answers
DICTIONARY
A dictionary is a listing of words in one or more specific languages, often arranged alphabetically, which may include information on definitions, usage, etymologies, pronunciations, translation, etc. or a book of words in one language with their equivalents in another, sometimes known as a lexicon.
Accessing Elements from Dictionary
Keys can be used either inside square brackets [] or with the get() method. If we use the square brackets [] , Key Error is raised in case a key is not found in the dictionary. On the other hand, the get() method returns None if the key is not found.
To access dictionary elements, you can use the familiar square brackets along with the key to obtain its value. Following is a simple example.
Answer:
A dictionary is a listing of lexemes from the lexicon of one or more specific languages, often arranged alphabetically, which may include information on definitions, usage, etymologies, pronunciations, translation, etc.. It is a lexicographical reference that shows inter-relationships among the data.
Accessing Elements from Dictionary
While indexing is used with other data types to access values, a dictionary uses keys . Keys can be used either inside square brackets [] or with the get() method. If we use the square brackets [] , KeyError is raised in case a key is not found in the dictionary.