The goal is to transform a dictionary into a list of tuples where the key will be the first part of the tuple and the value the second part. To do this in Python we can use comprehensions:
data = {'a': (1, 2), 'b': (3, 4, 5), 'c': (6, 7)} tuples = [(key, value) for key, value in data.items()] assert ('a', (1, 2)) in tuples assert ('b', (3, 4, 5)) in tuples assert ('c', (6, 7)) in tuples
But this is a little bit verbose, isn't it? A simpler solution exists though:
data = {'a': (1, 2), 'b': (3, 4, 5), 'c': (6, 7)} tuples = list(data.items()) assert ('a', (1, 2)) in tuples assert ('b', (3, 4, 5)) in tuples assert ('c', (6, 7)) in tuples