for i in len(nums):
n=len(nums)
for m in n:
if nums[i]+nums[m]==target :
return [i,m]
Python写循环程序的时候遇到 TypeError: ‘int’ object is not iterable,原因是循环中使用的应该是一组数
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for i in range(len(nums)):
n=len(nums)
for m in range(n):
if nums[i]+nums[m]==target :
return [i,m]
最后
以上就是优雅身影最近收集整理的关于TypeError: 'int' object is not iterable的全部内容,更多相关TypeError:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复