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
如何在Python中找到列表的编号?_Python_List - Fatal编程技术网

如何在Python中找到列表的编号?

如何在Python中找到列表的编号?,python,list,Python,List,你能帮我查一下列表的编号吗?我想知道有多少张名单 from itertools import permutations perm = permutations([0,1,2,3,4,5,6,7,8,9],4) for i in list(perm): if 1 in i and 3 in i: print (i) 输出(一点) 创建一个变量来计算它们,而不是打印它们 one_and_three_count = 0 for i in list(perm):

你能帮我查一下列表的编号吗?我想知道有多少张名单

from itertools import permutations

perm = permutations([0,1,2,3,4,5,6,7,8,9],4)

for i in list(perm):
    
    if 1 in i and 3 in i:
        print (i)
输出(一点)


创建一个变量来计算它们,而不是打印它们

one_and_three_count = 0
for i in list(perm):
    if 1 in i and 3 in i:
        one_and_three_count += 1
print("Number of lists containing 1 and 3:", one_and_three_count)
请浏览、和,以了解此网站的工作原理,并帮助您改进当前和未来的问题,从而帮助您获得更好的答案。您的描述和输出不匹配。
one_and_three_count = 0
for i in list(perm):
    if 1 in i and 3 in i:
        one_and_three_count += 1
print("Number of lists containing 1 and 3:", one_and_three_count)