Write a function named list_to_dict that accepts a list of tuples L as argument. Each element of L is of the form (x, y). It should return a dictionary D such that each tuple (x, y) corresponds to a key-value pair in D, that is, D[x] == y.
You can assume that if (x1, y1) and (x2, y2) are two different elements of L, then x1 != x2. Why is this assumption important?
You do not have to accept input from the user or print anything. You just have to write the definition of the function.
Example
list_to_dict([('a', 1), ('b', 2)]) -> {'a': 1, 'b': 2}
list_to_dict([]) -> {}
Implement this function:
def list_to_dict(L):
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: L.
Input
[('a', 1), ('b', 2)]
Output
{'a': 1, 'b': 2}