Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 如何确定列表中的一个字符串是另一个列表中另一个字符串的子字符串的次数?_List - Fatal编程技术网

List 如何确定列表中的一个字符串是另一个列表中另一个字符串的子字符串的次数?

List 如何确定列表中的一个字符串是另一个列表中另一个字符串的子字符串的次数?,list,List,基本上,我必须创建字符串列表 list_one = ["a", "b", "c"] list_two = ["arrr", "aaa", "acacb"] 预期输出为9,因为“a”、“b”和“c”出现9次。 对不起我的英语 首先,请告诉我们您使用的是什么语言,您尝试过什么解决方案 既然你称它为列表,我就假设它是python counter = [] for s in list

基本上,我必须创建字符串列表

list_one = ["a", "b", "c"]
list_two = ["arrr", "aaa", "acacb"]
预期输出为9,因为“a”、“b”和“c”出现9次。
对不起我的英语

首先,请告诉我们您使用的是什么语言,您尝试过什么解决方案

既然你称它为列表,我就假设它是python

counter = []
for s in list_one:
    temp = list(map(lambda x: x.count(s), list_two))
    counter.append(sum(temp))

output = sum(counter)

如果不是python,请尝试理解其逻辑并将其应用到您正在使用的语言中

您尝试了什么?您使用的是什么语言?请添加语言标记。