So I understand this simple `for` loop:

```
sum = 0
for number in {1,2,3,4}:
    sum = sum + number
    print sum

>>> 
1
3
6
10
>>> 

```

Then here is a neat little code that combines a `for` loop and a function I found on the interwebs:

```
def sum_list(l):
    sum = 0
    for number in l:
        sum = sum + number
    return sum

print sum_list([1, 7, 4])

>>> 
12

```

What I don't understand is how python interprets this code (rather how Python knows to add the 3 arguments 1,7,4 together).

I would really help if you can break it down for me!

---

To tack on another question for you guys to review:

```
sum = 0
for number in {1,2,3,4}:
    sum = sum + number
    return sum

```

Spits out an error. `print sum` will list the results as `1,3,6,10`

Error says: ***Syntaxerror: 'return' outside of function***

---

**[EDIT] @sshashank124**

For example: This code spits out 3 answers. It prints out:

```
sum = 0
for number in {1,7,4}:
    sum = sum + number
    print sum

>>> 
1
8
12 
>>> 

```

But this: 

```
def sum_list(l):
    sum= 0
    for number in l:
        sum = sum + number
    print sum
print sum_list([1, 7, 4])

>>> 
12
none

```

Spits out only 1 answer, `12`. My question is why that occurs.