Python How to make a dictionary from two lists?

We have two lists. And we want to create a dictionary combining values of these two lists. In such case, we can create a dictionary from two lists as following way. Example name_list=[“rahul”,”vijay”,”ajay”] phone_list=[“1111″,”2222″,”3333”] #declare an empty dictionary phone_book={} for idnum in range(0,len(name_list)): phone_book.add(name_list[idnum],phone_list[idnum]) #lets print the dictionary print(phone_book) Output: { “rahul”:”1111″, “vijay”:”2222″ “ajay”:”3333″ } […]

Python Dictionary

There are situations where we may want to store key and value pair data in a variable. Dictionary Dictionary in python: Variable which holds data in key and value pair form is known as dictionary. Example: registration_numbers={“Rahul”:”99ik89lm”, “Ajay”:”99ik90lm”, “Vijay”:”99ik91lm”, “Sachin”:”99ik92lm”, “Krishna”:”99ik933lm”} How to print data from a dictionary variable in python? To print a value […]

Python Data Types

In one of the previous tutorial, I have discussed about variable declaration. Variable are declared to store values in it. We can store different types of values in a variable. Lets learn in this tutorial, what are the different types of data we can store in a variable. String String data type are the general […]