Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize multiple assignment by python

Shulou Source: shulou.com Published: 2022-06-01 04:52:00 10月04日 Update

This article mainly shows you "how python realizes multiple assignment". The content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn this article "how python realizes multiple assignment".

multiple assignment

Have you ever wanted to reduce the number of lines of code used to create multiple variables, lists, or dictionaries? Well, you can do this easily with multiple assignments.

#Original operation a = 1b = 2c = 3#Alternative operations a, b, c = 1, 2, 3#Instead of creating multiple lists in different rows data_1 = []data_2 = [] data_3 = []data_4 = []#Multiple assignments of them can be created in one row data_1, data_2, data_3, data_4 = [], [],[],[]#Or use the list understanding method data_1, data_2, data_3, data_4 = [[] for i in range(4)] The above is "Python how to achieve multiple assignment" All the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Tags: Content article multiple Zhongchuang learning help original one line code variable dictionary easy to understand more organization knowledge editing industry information information channel channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno vpn Xiaomi Microsoft Shulou Tech Info