func.py
450 Bytes
def new_input():
total = []
while True:
unit= input("请输入:")
if unit== 'q':
break
else:
try:
unit=int(unit)
except:
print('请输入整数啊')
else:
total.append(unit)
return total
def sum(total):
count=0
for i in total:
count += i
return count
a = new_input()
print(sum(a))