func.py
443 Bytes
def a():
total = []
while True:
unit= input("请输入:")
if unit== 'q':
break
else:
try:
unit=int(unit)
except:
print('请重新输入一个数字')
else:
total.append(unit)
return total
def sum(money):
c=0
for i in money:
c=c+i
return c
b=a()
pay=sum(b)
print('您一共消费'+str(pay))