func.py
424 Bytes
def total():
total = []
while True:
unit= input("请输入:")
if unit== 'q':
break
else:
try:
unit=int(unit)
total.append(unit)
except:
print("请输入一个整数")
return total
def sum(money):
h=0
for i in money:
h=h+i
return h
result = total()
result1=sum(result)
print(result1)