Commit f5350e04 by BellCodeEditor

auto save

parent e837167e
Showing with 16 additions and 9 deletions
total = []#总的价格
while True:#重复执行
unit= input("请输入:")#输入价格
if unit== 'q':#如果输入是q
break#退出循环
else:
total.append(unit)列表里追加新元素
print(total)
\ No newline at end of file
def new_input():
total = []#总的价格
while True:#重复执行
unit= input("请输入:")#输入价格
if unit== 'q':#如果输入是q
break#退出循环
else:#否则
try:#尝试输入
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