How to Create Nested Dictionary in Python with 3 lists

You can create the dictionary from zip-ed lists and convert the int values to strings – if I understood your question proper

dct = {x: {str(y): str(z)} for x, y, z in zip(a,b,c)}

Output:

{'A': {'1': '9'}, 'C': {'3': '7'}, 'B': {'2': '8'}, 'D': {'4': '6'}}

Leave a Comment