Commit f5350e04 by BellCodeEditor

auto save

parent e837167e
Showing with 16 additions and 9 deletions
total = []#总的价格 def new_input():
while True:#重复执行 total = []#总的价格
unit= input("请输入:")#输入价格 while True:#重复执行
if unit== 'q':#如果输入是q unit= input("请输入:")#输入价格
break#退出循环 if unit== 'q':#如果输入是q
else: break#退出循环
total.append(unit)列表里追加新元素 else:#否则
print(total) try:#尝试输入
\ No newline at end of file unit = int(unit)
except:#如果错了就会打印下面的内容
print("请输入一个数字")
else:#输入正确显示
total.append(unit)#列表里追加新元素
print(total)#显示到列表
new_input()#调用函数
\ 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