Preview:
nums = [2,7,11,15]
target=9
dic={}
for i in range (len(nums)):
    d=target-nums[i]
    
    if d in dic:
        print(dic[d],i)
    else:
        dic[nums[i]]=i
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter