Convert nested tuple to custom key dictionary

sample_tuple = ((4, 'Gfg', 10), (3, 'is', 8), (6, 'Best', 10))

print("The original tuple : " + str(sample_tuple))

res = [{'key': sub[0], 'value': sub[1], 'id': sub[2]} for sub in sample_tuple]

print("The converted dictionary : " + str(res))


No comments: