如何在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)