Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the operations related to Python list list and dictionary dict

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "Python list list and dictionary dict related operations", the article explains the content is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Python list list and dictionary dict related operations have" it!

Topic 1 given a list of strings, find the one in which the length of the string is greater than 2 and the first character is the same as the last character, and return the index position. 2 there is a list of two letters pgraine Q, given a number such as n, and then appending 1 to n after the two letters to form a new list. Input: 4, output: ['p1lists,' Q1lists, 'p2lists,' Q2lists, 'p3lists,' Q3lists, 'p4lists,' q4'] 3 combine two lists into a list composed of dictionaries, where the name of the list is k, each value is v, and one-to-one input: color_name = ["Black", "Red", "Maroon", "Yellow"]

Color_code = ["# 000000", "# FF0000", "# 800000", "# FFFF00"]

Output: [{'color_name':' Black', 'color_code':' # 000000'}, {'color_name':' Red', 'color_code':' # FF0000'}, {'color_nam

Answer: 'Maroon',' color_code':'# 800000'}, {'color_name':' Yellow', 'color_code':' # FFFF00'}]

By the way, I deliberately left out the key line in the code of each solution, so you can try to complete it yourself and write it to the comments section.

1def match_words (words):

Ctr = 0

For word in words:

# add this sentence

Ctr + = 1

Return ctr

Print (match_words (['abc',' xyz', 'aba',' 1221']) 2my_list = ['paired,' q']

N = 4

New_list =? # DE8UG hint: consider string concatenation within a certain range

Print (new_list) 3color_name = ["Black", "Red", "Maroon", "Yellow"]

Color_code = ["# 000000", "# FF0000", "# 800000", "# FFFF00"]

Print ([{'color_name': f,' color_code': c} for f, c in?]) # DE8UG hint: zip give it a try?

Thank you for your reading, the above is the content of "what are the operations related to the Python list list and the dictionary dict". After the study of this article, I believe you have a deeper understanding of the operation of the Python list list and the dictionary dict, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report