In this python dictionary program, we will convert given a dictionary to a list of tuples.
Steps to solve the program
- Take a dictionary as input.
- Convert the dictionary to a list of tuples using list() and items().
- Print the output.
D1 = {'a':19,'b':20,'c':21,'d':20}
l = list(D1.items())
print(l)
Output :
[('a', 19), ('b', 20), ('c', 21), ('d', 20)]