Get the App
SLTechnology News&Howtos  ›  Development  › 

How python converts two lists into dictionaries

Shulou Source: shulou.com Published: 2022-06-01 05:15:27 09月20日 Update

Editor to share with you how python converts the two lists into dictionaries, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!

Convert two lists into dictionaries

The following method will convert two lists into a single dictionary.

Def to_dictionary (keys, values): return dict (zip (keys, values)) keys = ["a", "b", "c"] values = [2,3,4] print (to_dictionary (keys, values)) # {'averse: 2,' cession: 4, 'breadth: 3} what are the data types of python? data type of python: 1. Numeric types, including int (integer), long (long integer), and float (floating point). two。 String, which is of type str and type unicode, respectively. 3. Boolean, Python Boolean is also used for logical operations and has two values: True (true) and False (false). 4. List, the list is the most frequently used data type in Python, and any data type can be placed in the collection. 5. Tuples are identified by "()", and internal elements are separated by commas. 6. A dictionary is a collection of key-value pairs. 7. A collection is an unordered, non-repeating combination of data.

These are all the contents of the article "how python converts two lists into dictionaries". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Type dictionary two data article content Boolean frequent less element single most character string number method more identity floating point knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Xiaomi macOS Microsoft Shulou Information