number_list = [1, 2, 3, 4, 5]
def addition(number_list):
result = 0
for number in number_list: # the for loop will iterate every number of your list one by one
result += number # Which does the same as result = result + number
return result
# if you want to see the result in the terminal, you can print the result with:
print(addition(number_list))
1条答案
按热度按时间k2fxgqgv1#
你必须使用一个列表。这里有一个例子。