Lesson 13.3
PEP8 is the agreement on how to write code so that others can read it easily:
def sum_all(values): # function names are snake_case
total = 0 # indentation is 4 spaces
for value in values:
total = total + value
return total
a + b, f(a, b), not a+b, f(a,b);CamelCase is left for classes: class Hero is right, def Sum is not;black and ruff will format the code for you.The check gives the list of numbers numbers. Write a function named sum_positive
— that is the only way it will be found — and print the sum of the positive numbers.
Important: in this lesson the function name is part of the task. Even if the code counts
correctly, def SumPositive(...) won't pass: variable and function names start with a
small letter.
The function name is part of the task: small letters and underscores, no CamelCase.
Inside — a loop with the check number > 0 and adding to the sum. Don't change the
order of the print calls: the result is one number.