题目描述请点击查看LeetCode 题目描述
Python3 代码解答如下:
class Solution:
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
for a in nums:
#print(a, nums.index(a))
aIndex = nums.index(a)
for i in range(aIndex+1, len(nums)):
if a + nums[i] == target:
return [aIndex, i]