Ask coding questions

← Back to all posts
When I return True or False, it doesn't return anything
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

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:

SumZero(a)

Answered by Coder100 (19280) [earned 5 cycles]
View Answer
Comments
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)

mark as correct answer? @BhaiBhai

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