Commit 64ae0912 by BellCodeEditor

auto save

parent 3c1e179b
Showing with 22 additions and 4 deletions
......@@ -5,6 +5,24 @@ def new_input():
if unit== 'q':
break
else:
total.append(unit) # 列表名.append()方法添加元素unit
print(total)
new_input()
\ No newline at end of file
try: # 尝试执行
unit = int(unit)
except: # 报错则执行
print("请重新输入一个数字")
else:
total.append(unit)
finally:
print("=====================")
return total
def sum(money):
count = 0
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