Python Dictionaries

What is the dictionary in python?

Dictionary is used to store elements in variable using key:value pairs.
Curly braces {} are used to define a dictionary.
Dictionary stores different-different data type value like int,float,string,list,tuple,etc.
A dictionary is a collection which is changale and do not allow duplicate key.

Syntax

dictionary_name = {key:value,key:value}

See Output

How to get dictionary length

len() function used to get dictionary length. If you want to know how many items in a dictionary then you can use len() function. len() function very useful when you write logic in your program.

See Output

Data Type of Dictionary

type() function used to get data type of dictionary.

See Output

Access Items from python dictionary

Write dictionary key name inside square brackets to get an item of dictionary. get() method is also used to get an item from dictionary.

See Output

About Us

Comsysapp.com is an educational website. Students and software developers can learn programming language tutorials. Comsysapp is very useful for beginners and professional developers. Comsysapp provides tutorial in easy language. Comsysapp.com has focus on simplicity.

Services

Comsysapp.com provides free tutorials like c, html, css, etc. All tutorials are free for beginner and professionals.


Terms of Use

comsysapp.com is not responsible for any mistake. We are not responsible if information made available on our website is incomplete or invalid. But comsysapp.com always try for zero-zero mistake.

Privacy policy

comsysapp.com does not collect any data from users. We use Google AdSense advertising on our website. We never ask personal or private information.


Sitemap

sitemap

copyright © 2023