diff --git a/func.py b/func.py new file mode 100644 index 0000000..d9ba5f5 --- /dev/null +++ b/func.py @@ -0,0 +1,25 @@ +def new_input(): + total = [] + while True: + unit= input("请输入:") + if unit== 'q': + break + else: + try: + unit=int(unit) + except: + print("请重新输入") + else: + total.append(unit) + finally: + print("- "*30) + return total + +def sum(money): + he=0 + for i in money: + he=he+i + return he +a=new_input() +pay=sum(a) +print("一共花了"+str(pay)+"元,扫码还是现金?") \ No newline at end of file