diff --git a/func.py b/func.py new file mode 100644 index 0000000..9813992 --- /dev/null +++ b/func.py @@ -0,0 +1,38 @@ +# total = [] +# while True: +# unit= input("请输入:") +# if unit== 'q': +# break +# else: +# total.append(unit) +# print(total) + + +def put_money(): + wallet=[] + while True: + money=input("输入整数价格(按'q'结算):") + if money=="q": + print("已退出") + break + try: + int(money) + wallet.append(money) + print("当前钱包内有:"+str(",".join(wallet))) + except: + print("记得输入整数") + print("-"*30) + print("结算:") + print("当前钱包内有"+str(",".join(wallet))) + return wallet +result_wallet=put_money() +#print(result_wallet) + +def get_allmoney(list): + all_money=0 + for i in list: + all_money=all_money+int(i) + return all_money +result_getallmoney=get_allmoney(result_wallet) +print("总和为:"+str(result_getallmoney)) +