0

I found this example script on Leetcode supposed to find two values from a list that add up to the target number (always with 1 correct answer available upon input) but I've never used enumerate and don't know what it does. Can someone please help?

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        empty={}
        for index, number in enumerate(nums):
            if target-number in empty:
                return [empty[target-number],index]
            empty[number]=index

0 Answers0