Question: PYTHON Given two lists containing the names of states and their corresponding capitals, construct a dictionary which maps the states with their respective capitals. Let's

PYTHONPYTHON Given two lists containing the names of states and their corresponding

Given two lists containing the names of states and their corresponding capitals, construct a dictionary which maps the states with their respective capitals. Let's see how to do this using for loops and dictionary comprehension. Hint: you can use zip(iteratorl, iterator2) function, which is an iterator of tuples where the first item in each passed iterator is paired together and return an object. . For example: state = ['Gujarat', 'Maharashtra', 'Rajasthan'] capital = ['Gandhinagar', 'Mumbai', 'Jaipur'] Output: Output Dictionary using for loop: { 'Gujarat': 'Gandhinagar', 'Maharashtra': 'Mumbai', 'Rajasthan': 'Jaipur'}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!