Dictionary in another built-in data type in Python. Below are major points with Dictionaries:
- Dictionaries have key-value pair
- Each key:value pair is called an item in dictionary
- items of a dictionary are enclosed between {}
- items of dictionary can be changed after it's creation. changed means add or remove
- key in a dictionary is unique
- key can be integer, float, string
- items can have duplicates
The syntax of dictionary is,
Dictionary-name = {key:value}
Below is the example declaration of dictionary:
name = {1:"TalentEve",2:"Embeddeddesignblog",3:"YouTube-Way2Know",4:"Myvision-thisworld"}
The below declaration is allowed with a duplicate value:
name = {1:"TalentEve",2:"Embeddeddesignblog",3:"YouTube-Way2Know",4:"Myvision-thisworld",5:"TalentEve"}
Value is can be an integer, string, float, tuple,list etc
name = {1:1,2:2.2,3:"YouTube-Way2Know",4:[1,2,3],5:(1,2,3)}
0 Comments