Write a function named dict_to_list that accepts a dictionary D as argument. It should return the key-value pairs in D as a list L of tuples. That is, every element of L should be of the form (key, value) such that D[key] == value, and every key-value pair in the dictionary should be present as a tuple in L.
Append the pairs in the order in which they appear in D.
You do not have to accept input from the user or print anything. You just have to write the definition of the function.
Example
dict_to_list({'a': 1, 'b': 2}) -> [('a', 1), ('b', 2)]
dict_to_list({}) -> []
Implement this function:
def dict_to_list(D):
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: D.
Input
{'a': 1, 'b': 2}
Output
[('a', 1), ('b', 2)]