How to add data to empty dictionary and types of data a dictionary can store

How to add data to empty dictionary and types of data a dictionary can store

which types of data a dictionary can store ?

Anything eg – numbers , strings , list ,dictionary

 Variables can hold values of different data types. Python is a dynamically typed language hence we need not define the type of the variable while declaring it. The interpreter implicitly binds the value with its type.

Python enables us to check the type of the variable used in the program. Python provides us the type() function which returns the type of the variable passed.


user_info = {
'name' : 'pramod',
'age' : 22 ,
'rollno' :'17691a05b9',
'class' : 'B-Tech'}
print(user_info['name'])
 print(user_info['age'])
 print(user_info['rollno'])
 print(user_info['class'])

How to add data to empty dictionary


user_info2 = {}
user_info2['name']='prem kumar'user_info2['age']=22
 print(user_info2)

How to add data to empty dictionary and types of data a dictionary can store

Leave a Comment

Your email address will not be published. Required fields are marked *