Commit 192928a8 by BellCodeEditor

save project

parent 7b52fe6f
Showing with 21 additions and 2 deletions
def new_input():#新建一个函数
total = []#建立一个空价格列表
while True:
unit = input("请输入(q退出):")#输入内容的提示
monetmonet = input("请输入(q退出):")#输入内容的提示
if unit == "q":#如果输入q
break#终止程序
else:#否则
try:
unit = int(unit)#输入一个整数
except:#
print("请输入一个数字")如果我输入的不是整数的提示
print("请输入一个数字")#如果我输入的不是整数的提示
else:
total.append(unit)#如果我输入的是整数的话就把这个整数添加到total中
print("-"*30)#一个分界线
......
def new_input():
total = []
while True:
money = input("请输入(q退出):")
if money == "q":
break
else:
try:
money = int(money)
except:
print("请重新输入一个数字")
else:
total.append(money)
finally:
print("-"*30)
return total
result = new_input()
print(result)
\ 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