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