class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ num_list = [] for i in range(len(nums)): for j in nums: if nums[i] + j == target and i != nums.index(j): if len(num_list) < 2: num_list.append(nums[i]) num_list.append(j) index = 0 nums_ind = [] for j in nums: if nums[index] in num_list: nums_ind.append(index) index+=1 return nums_ind