Start learning free

LESSON 169 OF 673 · LOOPS & GLOBAL VARIABLES

List Sum: Buggy Code in Python

Practice

Inside the code editor we've tried to write a function that takes a list nums as argument and prints to the console the sum of all numbers in that list.

So when we called print_sum([1, 2, 3]), we expected our code to print:

6

because 1 + 2 + 3 = 6. But it seems like we made some mistakes because when we run our code, it prints:

1
2
3

Assignment:

Your task is to fix our function such that it correctly computes and prints the desired sum.

STEP 1 OF 1
    Ctrl + Enter to check