Lists + Functions Example


#1

def count_small(numbers):
    total = 0
    for n in numbers:
        if n < 10:
            total = total + 1
    return total

lost = [4, 8, 15, 16, 23, 42]
small = count_small(lost)
print small

I have a question about this example. I did the example in the terminal, even in a text editor. It prints 1 instead of 2. Can some please one explain why is that?


#2

Never mind, found the issue, I was indenting "return total" on the same line as if statement in the terminal and in the text editor :slightly_smiling: