求各位god看看
正常输出不应该是[0,1]吗
为什么会继续循环输出[0,1,1,0]呢
class Solution(object):
def twoSum(self, nums, target):
self.nums = nums
self.target = target
output = []
while len(output) <2:
for i in range(len(nums)):
number1 = nums[i]
left = target - number1
if left in nums:
output.append(i)
output.append(nums.index(left))
print(output)
print(len(output))
nums = [2,7,11,15]
target = 9
hello = Solution()
hello.twoSum(nums,target)