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

Count the number of times that the initials of each name appear in the name list

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Name_list= ['foster', "janet",' jessus','david'] count_dict= {} for i in name_list: count_ print count_dict [I] = ".join (name_list) .count (I [0]) print count_dict > > def countfist (a):... Res = {}... For i in a:... Res [I] = "" .join (a) .count (I [0]).. Return res... > countfist (new_mystr) {'and': 3,' world': 1, 'itcastcpp': 2,' itcast': 2, 'hello': 1} > name_list= [' foster', "janet", 'jessus','david'] > countfist (name_list) {' david': 2, 'foster': 1,' janet': 2, 'jessus': 2} >

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