Saturday 6 November 2021

Python: dict(): Create a dictionary

‘dict()’ is used to create a dictionary.

 

Example

empDict = dict(name = "Krishna", age = 36, id = 1)

 

create_dict_using_dict_function.py

empDict = dict(name = "Krishna", age = 36, id = 1)

print(empDict)

 

Output

{'name': 'Krishna', 'age': 36, 'id': 1}

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment