
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
In Python how to create dictionary from two lists?
If L1 and L2 are list objects containing keys and respective values, following list comprehension syntax can be used to construct dictionary object.
>>> L1 = ['a','b','c','d'] >>> L2 = [1,2,3,4] >>> d = {L1[k]:L2[k] for k in range(len(L1))} >>> d {'a': 1, 'b': 2, 'c': 3, 'd': 4}
- Related Questions & Answers
- How to map two lists into a dictionary in Python?
- Python - Ways to create a dictionary of Lists
- Convert two lists into a dictionary in Python
- Python – Cross mapping of Two dictionary value lists
- How to create Python dictionary from JSON input?
- How to create Python dictionary from the value of another dictionary?
- How to create a Python dictionary from text file?
- How to compare two lists in Python?
- How to create a Pandas series from a python dictionary?
- How to create nested Python dictionary?
- Python – Create dictionary from the list
- How to create a dictionary in Python?
- Program to find minimum difference between two elements from two lists in Python
- How to Create and Assign Lists in Python?
- Python program to create a dictionary from a string
Advertisements