gpt4 book ai didi

python - 下一个(h) TypeError : 'int' object is not an iterator

转载 作者:太空宇宙 更新时间:2023-11-04 08:32:21 32 4
gpt4 key购买 nike

这个 block 代码给我这个错误'TypeError: 'int' object is not an iterator'。我找不到问题所在,因为我有一个几乎完全相同的程序,而且运行良好。

else:
v3=r
for h in range(0,len(oddnums)):

if v1+v2+v3+v4==totalvals:
temp=[v1,v2,v3,v4]
combinations.append(temp)
else:
next(h)
print()

这里是完整的源代码: 全局奇数 全局温度 全局组合 全局组合 全局经济 全局总值 全局范围 全局 v4

 for i in range (0 ,len(oddnums)):
v1=oddnums[i]
if i>=totalvals:
next(i)
print()
else:
print("v1")
#print(v1)
for x in range (0,len(oddnums)):
v2=oddnums[x]
print('v2')
total=x+i
if total >=totalvals:
next(x)
print()
else:
rem=totalvals-(x+i)
if rem<4:
next(x)
print()
else:
print()

for r in range (0,len(oddnums)):

#print('v3')
count += 1
#print(count)

lrem = rem - oddnums[r]
if lrem<1:
next(r)
print('no val')
else:
v3=r
for h in range(0,len(oddnums)):

if v1+v2+v3+v4==totalvals:
temp=[v1,v2,v3,v4]
combinations.append(temp)
else:
next(h)
print()
my_method()

完整错误信息:

追溯(最近的调用最后):你好 文件“C:/Users/willf/Documents/Transition Task/question1/src/com/companyBoolean/4waycombo.py”,第 92 行,在v1 我的方法()v2

文件“C:/Users/willf/Documents/Transition Task/question1/src/com/companyBoolean/4waycombo.py”,第 84 行,在 my_method 中 下一个(小时)TypeError: 'int' 对象不是迭代器

进程结束,退出代码为 1

最佳答案

问题在于尝试使用 next(i)next(x)ix 是由 range 迭代器生成的整数,而不是迭代器本身。

将这些行更改为 continue,您应该没问题。

关于python - 下一个(h) TypeError : 'int' object is not an iterator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51899662/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com