Python Dictionaries

Python3 Dictionaries

This lecture you will learn python Dictionaries!

Dictionaries in Python

Using dictionaries with a bunch of key value pairs, 

These are key value pairs 

Name = test
Email =
Phone = 23433

 Will see now how to define and use dictionary in Python
 Keys would be unique on dictionary 

customer = {
    "name": "krish",
    "age": 22,
    "is_verified": True


if we pass the name which is not available in dictionary which will returns key error 
and also we can use get method to get the key value pairs 


in this scenario if the key is not available it would be print None says that object is not available.

Updating the dictionary values as well 
customer = {
    "name": "krish",
    "age": 22,
    "is_verified": True
customer["name"] = "John"

also add new key value pairs here like
customer["email"] = ""

Complete python course
Print  1234  users phone number in words for an example
phone = input("Phone: ")
mapping = {
    "1": "One",
    "2": "Two",
    "3": "Three",
    "4": "Four"
output = ""
for ch in phone:
    output += mapping.get(ch, "!") + " "

Phone: 1235
One Two Three !

Python data science interview questions and answers python is a high-level programming language using Data Science programs these days

Data Science

Web development fullstack course Web development course 2021: Fullstack
Online course Online Courses: Include Certification
Harisystems is optimized for learning, testing and training. courses are designed to be simplified to improve reading and basic understanding for beginners to expert level. Tutorials and examples are constantly reviewed to avoid errors, however we cannot warrant full correctness of all content. if any found need to correct write us at we Harisystems is not responsible for any with this tutorials, While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2007-2020 by Harisystems. All Rights Reserved.
Copyright © Harisystems 2020