Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23160

How to create one dictonary using 3 lists

$
0
0

I am new to Python and need help creating one dictionary file using three lists.

example:

list 1 = ["private", "private"]list 2 = ["10.1.1.1", "10.11.11.11"]list3 = [ "sfc", "gfc"]

my code:

dict = {}for s in range(len(list1)):       dict[list1[s]] =  {list2[s]: list3[s]}print(dict)

I am getting output as {'private': {'10.1.1.1': 'sfc'}}

but I want output as {'private': {'10.1.1.1': 'sfc'}, {'10.11.11.11': 'gfx'}}

Could somebody help me on how to get in this format?


Viewing all articles
Browse latest Browse all 23160

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>