Listing 08-02: How not to write a function

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 08\08.02 - How not to write a function.py
# Description: How not to write a function
##############################################################################

def sum(L):
    total = 0
    x = 0
    while x < 5:
        total += L[x]
        x += 1
    return total
L = [1, 7, 2, 9, 15]
print(sum(L))
print(sum([7, 9, 12, 3, 100, 20, 4]))
Click here to download the file