My leetcode submissions.
at main 396 B view raw
1class Solution(object): 2 def twoSum(self, nums, target): 3 """ 4 :type nums: List[int] 5 :type target: int 6 :rtype: List[int] 7 """ 8 for (i, n) in enumerate(nums): 9 c = target - n; 10 try: 11 j = nums.index(c) 12 except: 13 continue 14 if c in nums and i != j: 15 return [i, j]