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)
你需要使用一个列表。下面是一个例子。你知道吗
相关问题 更多 >
编程相关推荐