Commit 50b74375 by BellCodeEditor

auto save

parent 59ac2e58
Showing with 38 additions and 11 deletions
def new_input():
total = []
while True:
money=input("请输入(q退出):")
if money== 'q':
break
else:
try:
money=int(money)
except:
print("重新输入一个整数")
else:
total.append(money)
print("-"*30)
return total
try:
def new_input(): def new_input():
total = [] total = []
while True: while True:
except: unit = input('请输入(q退出):')
unit= input("请输入:") if unit == 'q':
if unit== 'q':
break break
print("要输入整数哦~") else:
else: try:
total.append(unit) unit = int(unit)
print(total) except:
new_input() print("请重新输入一个数字")
return total else:
total.append(unit)
finally:
print("=====================")
return total
def sum(money): def sum(money):
count=0 count = 0
for i in money: for i in money:
count = count + i
return count
price = new_input()
pay = sum(price)
print("您一共消费了" + str(pay) + "元!扫码还是现金呢?")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment