软件和我说“a is not defined”
a没有定义
得看代码哦
from itertools import product
n = [6, 16, 26, 36, 46, 56, 60,61,62,63,64,65,66,67,68,69, 76, 86, 96] # 所有包含6的数字
for a,b,c,d,e,f in product(n,repeat=6):
if a+b+c+d+e+f==100 and a>=b>=c>=d>=e>=f:
print(a,b,c,d,e,f)
输出:
60 16 6 6 6 6
如果对你有帮助,帮忙采纳一下!
你题目的解答代码如下:(如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮)
def fun():
p = [x for x in range(100) if '6' in str(x)] # 所有包含6的数字
for a in p:
for b in p:
for c in p:
for d in p:
for e in p:
for f in p:
if a+b+c+d+e+f==100:
return (a,b,c,d,e,f)
print(fun())
结果(6, 6, 6, 6, 16, 60)
输出3位到7位的所有水仙花数
for i in range(100,10000000):
if sum([int(x)**len(str(i)) for x in str(i)])==i:
print(i)
结果
153
370
371
407
1634
8208
9474
54748
92727
93084
548834
1741725
4210818
9800817
9926315
贴代码看看
你这不光a找不到,abced都没定义