func.py
445 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
a=new_input
def sum(total):
count=0
for i in total:
count+=i
return count
a=new_input()
print(sum(a))