← Back to all posts

# Write a function that takes in a list of integers (positive or negative) and returns True if any pair of the numbers in the list sum to 0, Otherwise, return False

a = [5,6,7,23,23,423,612,657,3423,46,-46,-5,-6,-23,-423,-3423]
b = [2344,536,23,42,462,342,5,325,32,3453,65,32]

def SumZero(lst):
for i in lst:

```.css-o0gntx{position:absolute;left:-9999px;}.css-1v1ju80{-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;border-width:0;border-style:solid;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-basis:auto;-ms-flex-preferred-size:auto;flex-basis:auto;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;position:relative;outline:none;min-height:0;min-width:0;position:absolute;left:-9999px;}for j in lst:

if i + j == 0:
return True

else:
return False```

SumZero(a)

Answered by Coder100 (19280) [earned 5 cycles]
hotnewtop
Coder100 (19280)

You didn't print the result to the console.

Change line 19 to: `print(SumZero(a))` to see the output!

Coder100 (19280)

BhaiBhai (0)

@Coder100 Sorry, I'm new here - I just did

BhaiBhai (0)

Did it mark as the correct answer, I am not sure if it did @Coder100

Coder100 (19280)

yep you did it correctly @BhaiBhai

CosmicBear (95)

What do you mean? It already returns `True` or `False`.

IMayBeMe (614)

It actually does return true or false, the only issue is that you not printing it. This is easy to fix as you can just print the function on the last line like this: `print(SumZero(a))`

BhaiBhai (0)

Write a function that takes in a list of integers (positive or negative) and returns True if any pair of the numbers in the list sum to 0, Otherwise, return False