Get the App
SLTechnology News&Howtos  ›  Development  › 

How python combines two lists into a dictionary

Shulou Source: shulou.com Published: 2022-06-01 04:43:58 10月03日 Update

This article will explain in detail how python combines the two lists into a dictionary. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Combine two lists into a dictionary

The zip code function has many advantages in python. Using the zip function, we can create dictionaries from two lists.

List_1 = ["One", "Two", "Three"] list_2 = [1Mae 2Mae 3] dictionary = dict (zip (list_1, list_2)) print (dictionary)

Output quantity

{'Two': 2,' One': 1, 'Three': 3} this is the end of the article on "how python combines two lists into dictionaries". I hope the above content can be helpful to you so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Two dictionaries articles more good practical advantages content functions functions articles knowledge zip code reference help related output Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Technology OPPO Reno Shulou Information Apple