Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started