0 votes
in Python by
Python has something called the dictionary. Explain using an example.

1 Answer

0 votes
by
A dictionary in Python programming language is an unordered collection of data values such as a map. Dictionary holds key:value pair. It helps in defining a one-to-one relationship between keys and values. Indexed by keys, a typical dictionary contains a pair of keys and corresponding values.

Let us take an example with three keys, namely Website, Language, and Offering. Their corresponding values are hackr.io, Python, and Tutorials. The code for the example will be:

dict={‘Website’:‘hackr.io’,‘Language’:‘Python’:‘Offering’:‘Tutorials’}

print dict[Website] #Prints hackr.io

print dict[Language] #Prints Python

print dict[Offering] #Prints Tutorials

Related questions

0 votes
asked Jan 10, 2021 in Python by rajeshsharma
0 votes
asked Dec 19, 2019 in Python by sharadyadav1986
...