How can I make a dictionary (dict) from separate lists of keys and values?
You can use the zip function to create a dictionary from separate lists of keys and values like this:
You can use the zip function to create a dictionary from separate lists of keys and values like this:
Using the zip function to create a dictionary from separate lists of keys and values in Python
python— editable, runs on the server
Info
Watch a video course: Python - The Practical Guide
Alternatively, you can also use the dict constructor and pass it a list of tuples, where each tuple consists of a key-value pair:
Using the dict constructor and pass it a list of tuples in Python
python— editable, runs on the server