#C13915. Create Dictionary from Two Lists
Create Dictionary from Two Lists
Create Dictionary from Two Lists
Given two lists, one of keys and the other of values, create a dictionary according to the following rule: if the two lists have different lengths, pad the shorter list with None (i.e. null) values. Formally, let ( A = [a_0,a_1,\dots,a_{m-1}] ) be the list of keys and ( B = [b_0,b_1,\dots,b_{n-1}] ) be the list of values. Define ( L = \max(m,n) ) and extend the missing entries with ( None ). Then build the dictionary ( D ) by pairing the ( i^{th} ) element of the padded key list with the ( i^{th} ) element of the padded value list for ( i = 0,1,\dots,L-1 ).
Note that if duplicate keys occur (for example, when padding keys that do not exist), the last corresponding value should be retained in the dictionary.
inputFormat
The input is given via standard input (stdin) in two lines.
The first line is a JSON array representing the keys.
The second line is a JSON array representing the values.
For example:
["one", "two", "three"]
[1, 2, 3]
outputFormat
Output the resulting dictionary (in Python dictionary literal style) to standard output (stdout).
For missing entries, use None. For example, if the keys are padded, output:
{'one': 1, 'two': 2, 'three': None}## sample
["one", "two", "three"]
[1, 2, 3]
{'one': 1, 'two': 2, 'three': 3}