Ask coding questions

← Back to all posts
Wont work
LeoMosley (0)

class Solution(object):
def twoSum(self, nums, target):
num = 0
add = 0
for i in range(len(nums)):
if (nums[num] - target) == 0:
for a in range(len(nums)):
if (nums[num] + nums[add]) == target:
add = add + 1
num = num + 1


InvisibleOne (2935)

Your code is working, you're looking to see if any of the numbers minus the target are equal to zero, since your target is nine, you would have to have a nine in your list of nums for it to do the next few lines of code.