Blue Week Special Offer | Brighten your week!
days
hours
minutes
seconds

Function Fundamentals

<Screen Link:

https://app.dataquest.io/m/315/functions%3A-fundamentals/1/functions

My Code:
a_list = [4444, 8897, 6340, 9896, 4835, 4324, 10, 6445,
661, 1246, 1000, 7429, 1376, 8121, 647, 1280,
3993, 4881, 9500, 6701, 1199, 6251, 4432, 37

int sum_manual = 0

for item in a_list:
sum_manual = sum_manual + item

print(sum_manual) >

Should this work as well? 

for item in a_list:
          sum_manual += item


What I expected to happen:

I expected to iterate through the list and add each element to the sum_manual variable declared above.

What actually happened:

My guess is that I don’t need to declare an int. Something else may be wrong.

File "<ipython-input-1-38fca43280a8>", line 6
    int sum_manual = 0
      ^
SyntaxError: invalid syntax

hey @hunter.kiely

  1. you are missing the closing bracket ] for a_list after 37.
  1. in python we don’t explicitly declare variables with their datatype.

sum_manual = 0 will implicitly create a variable of integer type. no need to add int.

  1. yes. this will work.
1 Like

Very helpful. Thanks

1 Like