Solution Review: A Sum of Zero
Review the solution for the "A Sum of Zero" exercise.
We'll cover the following...
Solution
Let’s explore the solution to the problem of A Sum of Zero.
Press + to interact
def check_sum(num_list):for first_num in range(len(num_list)):for second_num in range(first_num + 1, len(num_list)):if num_list[first_num] + num_list[second_num] == 0:return Truereturn Falsenum_list = [10, -14, 26, 5, -3, 13, -5]print(check_sum(num_list))
Explanation
Here’s a line-by-line explanation of the code for the A Sum of Zero problem:
Line 1: Defines the function
check_sum
...