func.py
536 Bytes
def new_input():
total = []
while True:
money = input("请输入:")
if money== 'q':
break
else:
try:
money = int(money)
except:
print("请重新输入一个数字")
else:
total.append(money)
print("-"*30)
return total
def sum(money):
count=0
for i in money:
count=count+1
return count
price = new_input()
pay = sum(price)
print("需呀支付"+str(pay)+"yuan")