我做了一个python函数,它假设从1-100打印出偶数并添加总和。我设法打印出总和,但数字不打印出来。
def main():
BuildList()
def BuildList():
lstEvens = []
for i in range(0,101):
if i % 2 == 0:
lstEvens.append(i)
SumList(lstEvens)
def SumList(lstEvens):
totalofEvens = sum(lstEvens)
ShowResults(totalofEvens)
def ShowResults(totalofEvens):
print("The sum of all Even numbers combined is" ,totalofEvens)
print(lstEvens)
main()
答案 0 :(得分:0)
lstEvens
未在函数ShowResults
中定义。