python整形不可迭代_python不能同时迭代两个列表

我的python代码有问题,但我不确定是什么问题。我正在创建一个程序,创建一个表,其中包含所有可能的四位数组合,前提是数字不重复,我知道这是成功的。然后,我创建了另一个表,并尝试将使用相同数字的所有值以不同的顺序添加到该辅助表中(因此,我在该表上没有1234、4321、3241、3214、1324、2413等)。但是,这似乎不起作用,因为第二个表只有一个值。我做错了什么?我的代码在下面。哦,我知道一个值来自于在顶部附加1。在combolisttwo = list()

combolisttwo.append(1)

combolist = {(a, b, c, d) for a in {1, 2, 3, 4, 5, 6, 7, 8, 9, 0} for b in {1, 2, 3, 4, 5, 6, 7, 8, 9, 0} for c in {1, 2, 3, 4, 5, 6, 7, 8, 9, 0} for d in {1, 2, 3, 4, 5, 6, 7, 8, 9, 0} if a != b and a != c and a != d and b != c and b != d and c!=d}

for i in combolist:

x = 0

letternums = str(i)

letters = list(letternums)

for g in letters:

n = 0

hits = 0

nonhits = 0

letterstwo = str(combolisttwo[n])

if g == letterstwo[n]:

hits = hits + 1

if g != letterstwo[n]:

nonhits = nonhits + 1

if hits == 4:

break

if hits + nonhits == 4:

combolisttwo.append(i)

break

x = len(combolisttwo)

print (x)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值