Unit 2 Session 1 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Create and fill a dictionary using two lists as the keys and values.
1) Create an empty dictionary
2) For each index in the keys/values lists
a) Get the key from the keys list at that index
b) Get the value from the values list at that index
c) Add the key:value pair to the new dictionary
3) Return the new dictionary
⚠️ Common Mistakes
def create_dictionary(keys, values):
result_dict = {}
for i in range(len(keys)):
result_dict[keys[i]] = values[i]
return result_dict